w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pdftoepdf.c
Go to the documentation of this file.
1 /*
2 pdftoepdf.w
3 
4 Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
5 Copyright 2006-2015 Taco Hoekwater <taco@luatex.org>
6 
7 This file is part of LuaTeX.
8 
9 LuaTeX is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13 
14 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
18 
19 You should have received a copy of the GNU General Public License along
20 with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #define __STDC_FORMAT_MACROS /* for PRId64 etc. */
24 
25 #include "image/epdf.h"
26 #include "luatexcallbackids.h"
27 
28 /* to be sorted out, we cannot include */
29 
30 #define xfree(a) do { free(a); a = NULL; } while (0)
31 
32 /* Conflict with pdfgen.h */
33 
34 #ifndef pdf_out
35 
36 #define pdf_out(pdf, A) do { pdf_room(pdf, 1); *(pdf->buf->p++) = A; } while (0)
37 
38 #define pdf_check_space(pdf) do { \
39  if (pdf->cave > 0) { \
40  pdf_out(pdf, ' '); \
41  pdf->cave = 0; \
42  } \
43 } while (0)
44 
45 #define pdf_set_space(pdf) \
46  pdf->cave = 1;
47 
48 #define pdf_reset_space(pdf) \
49  pdf->cave = 0;
50 
51 #endif
52 
53 /* Maintain AVL tree of all PDF files for embedding */
54 
56 
57 /* AVL sort PdfDocument into PdfDocumentTree by file_path */
58 
59 static int CompPdfDocument(const void *pa, const void *pb, void *p )
60 {
61  return strcmp(((const PdfDocument *) pa)->file_path, ((const PdfDocument *) pb)->file_path);
62 }
63 
64 /* Returns pointer to PdfDocument structure for PDF file. */
65 
66 static PdfDocument *findPdfDocument(char *file_path)
67 {
68  PdfDocument *pdf_doc, tmp;
69  if (file_path == NULL) {
70  normal_error("pdf backend","empty filename when loading pdf file");
71  } else if (PdfDocumentTree == NULL) {
72  return NULL;
73  }
74  tmp.file_path = file_path;
76  return pdf_doc;
77 }
78 
79 #define PDF_CHECKSUM_SIZE 32
80 
81 #if defined(_WIN32) /* --ak */
82 extern int utf8_stat(const char *path, struct stat *buffer);
83 #endif /* --ak */
84 
85 static char *get_file_checksum(const char *a, file_error_mode fe)
86 {
87  struct stat finfo;
88  char *ck = NULL;
89 #if defined(_WIN32) /* --ak */
90  if (utf8_stat(a, &finfo) == 0) {
91 #else /* _WIN32 --ak */
92  if (stat(a, &finfo) == 0) {
93 #endif /* _WIN32 --ak */
94  off_t size = finfo.st_size;
95  time_t mtime = finfo.st_mtime;
96  ck = (char *) malloc(PDF_CHECKSUM_SIZE);
97  if (ck == NULL)
98  formatted_error("pdf inclusion","out of memory while processing '%s'", a);
100  } else {
101  switch (fe) {
102  case FE_FAIL:
103  formatted_error("pdf inclusion","could not stat() file '%s'", a);
104  break;
105  case FE_RETURN_NULL:
106  if (ck != NULL)
107  free(ck);
108  ck = NULL;
109  break;
110  default:
111  assert(0);
112  }
113  }
114  return ck;
115 }
116 
117 static char *get_stream_checksum (const char *str, unsigned long long str_size){
118  /* http://www.cse.yorku.ca/~oz/hash.html */
119  /* djb2 */
120  unsigned long hash ;
121  char *ck = NULL;
122  unsigned int i;
123  hash = 5381;
124  ck = (char *) malloc(STRSTREAM_CHECKSUM_SIZE+1);
125  if (ck == NULL)
126  normal_error("pdf inclusion","out of memory while processing a memstream");
127  for(i=0; i<(unsigned int)(str_size); i++) {
128  hash = ((hash << 5) + hash) + str[i]; /* hash * 33 + str[i] */
129  }
131  ck[STRSTREAM_CHECKSUM_SIZE]='\0';
132  return ck;
133 }
134 
135 /*
136  Returns pointer to PdfDocument structure for PDF file.
137  Creates a new PdfDocument structure if it doesn't exist yet.
138  When fe = FE_RETURN_NULL, the function returns NULL in error case.
139 */
140 
141 PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe, const char *userpassword, const char *ownerpassword)
142 {
143  char *checksum, *path_copy;
145  ppdoc *pdfe = NULL;
146  int new_flag = 0;
147  if ((checksum = get_file_checksum(file_path, fe)) == NULL) {
148  return (PdfDocument *) NULL;
149  }
150  path_copy = xstrdup(file_path);
151  if ((pdf_doc = findPdfDocument(path_copy)) == NULL) {
152  new_flag = 1;
153  pdf_doc = (PdfDocument*) xmalloc(sizeof( PdfDocument));
154  pdf_doc->file_path = path_copy;
155  pdf_doc->checksum = checksum;
156  pdf_doc->pdfe = NULL;
157  pdf_doc->inObjList = NULL;
158  pdf_doc->ObjMapTree = NULL;
159  pdf_doc->occurences = 0; /* 0 = unreferenced */
160  pdf_doc->pc = 0;
161  pdf_doc->is_mem = 0;
162  } else {
163  if (strncmp(pdf_doc->checksum, checksum, PDF_CHECKSUM_SIZE) != 0) {
164  formatted_error("pdf inclusion","file has changed '%s'", file_path);
165  }
166  free(checksum);
167  free(path_copy);
168  }
169  if (pdf_doc->pdfe == NULL) {
170  pdfe = ppdoc_load(file_path);
171  pdf_doc->pc++;
172  /* todo: check if we might print the document */
173  if (pdfe == NULL) {
174  switch (fe) {
175  case FE_FAIL:
176  normal_error("pdf inclusion","reading image failed");
177  break;
178  case FE_RETURN_NULL:
179  if (pdf_doc->pdfe != NULL) {
180  ppdoc_free(pdfe);
181  pdf_doc->pdfe = NULL;
182  }
183  /* delete docName */
184  if (new_flag == 1) {
185  if (pdf_doc->file_path != NULL)
186  free(pdf_doc->file_path);
187  if (pdf_doc->checksum != NULL)
188  free(pdf_doc->checksum);
189  free(pdf_doc);
190  }
191  return (PdfDocument *) NULL;
192  break;
193  default:
194  assert(0);
195  }
196  }
197  if (pdfe != NULL) {
198  if (ppdoc_crypt_status(pdfe) < 0 && userpassword==NULL) {
199  formatted_error("pdf inclusion","the pdf file '%s' is encrypted, passwords wrong",file_path);
200  }
201  if (ppdoc_crypt_status(pdfe) < 0) {
202  ppdoc_crypt_pass(pdfe,userpassword,strlen(userpassword),NULL,0);
203  }
204  if (ppdoc_crypt_status(pdfe) < 0) {
205  ppdoc_crypt_pass(pdfe,NULL,0,ownerpassword,strlen(ownerpassword));
206  }
207  if (ppdoc_crypt_status(pdfe) < 0) {
208  formatted_error("pdf inclusion","the pdf file '%s' is encrypted, provide proper passwords",file_path);
209  }
210  }
211  pdf_doc->pdfe = pdfe;
212  }
213  /* PDF file could be opened without problems, checksum ok. */
214  if (PdfDocumentTree == NULL)
218  }
219  pdf_doc->occurences++;
220  return pdf_doc;
221 }
222 
223 /*
224  Returns pointer to PdfDocument structure for a PDF stream in memory of streamsize
225  dimension. As before, creates a new PdfDocument structure if it doesn't exist yet
226  with file_path = file_id
227 */
228 
229 PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streamsize,const char *file_id)
230 {
231  char *checksum;
232  char *file_path;
234  ppdoc *pdfe = NULL;
235  size_t cnt = 0;
237  cnt = strlen(file_id);
238  file_path = (char *) malloc(cnt+STREAM_URI_LEN+STRSTREAM_CHECKSUM_SIZE+1); /* 1 for \0 */
239  strcpy(file_path,STREAM_URI);
240  strcat(file_path,file_id);
241  strcat(file_path,checksum);
243  if ((pdf_doc = findPdfDocument(file_path)) == NULL) {
244  /*new_flag = 1;*/
245  pdf_doc = (PdfDocument*) xmalloc(sizeof( PdfDocument));
246  pdf_doc->file_path = file_path;
247  pdf_doc->checksum = checksum;
248  pdf_doc->pdfe = NULL;
249  pdf_doc->inObjList = NULL;
250  pdf_doc->ObjMapTree = NULL;
251  pdf_doc->occurences = 0; /* 0 = unreferenced */
252  pdf_doc->pc = 0;
253  pdf_doc->is_mem = 1;
254  pdf_doc->memstream = docstream;
255  } else {
256  /* As is now, checksum is in file_path, so this check should be useless. */
257  if (strncmp(pdf_doc->checksum, checksum, STRSTREAM_CHECKSUM_SIZE) != 0) {
258  formatted_error("pdf inclusion","stream has changed '%s'", file_path);
259  }
260  free(file_path);
261  free(checksum);
262  }
263  if (pdf_doc->pdfe == NULL) {
264  pdfe = ppdoc_mem(docstream, (size_t) streamsize);
265  pdf_doc->pc++;
266  if (pdfe == NULL) {
267  normal_error("pdf inclusion","reading pdf Stream failed");
268  }
269  pdf_doc->pdfe = pdfe;
270  }
271  /* PDF file could be opened without problems, checksum ok. */
272  if (PdfDocumentTree == NULL)
276  }
277  pdf_doc->occurences++;
278  return pdf_doc;
279 }
280 
281 /*
282  AVL sort ObjMap into ObjMapTree by object number and generation keep the ObjMap
283  struct small, as these are accumulated until the end
284 */
285 
286 typedef struct ObjMap ObjMap ;
287 
288 struct ObjMap {
289  /* int version; */ /* not really needed */
290  int objnum;
291  int out_num;
292 };
293 
294 static int CompObjMap(const void *pa, const void *pb, void *p)
295 {
296  const ObjMap *a = (((const ObjMap *) pa));
297  const ObjMap *b = (((const ObjMap *) pb));
298  if (a->objnum > b->objnum)
299  return 1;
300  else if (a->objnum < b->objnum)
301  return -1;
302  /*
303  else if (a->version == b->version)
304  return 0;
305  else if (a->version < b->version)
306  return -1;
307  return 1;
308  */
309  return 0;
310 }
311 
313 {
314  ObjMap *obj_map, tmp;
315  if (pdf_doc->ObjMapTree == NULL) {
316  return NULL;
317  }
318  tmp.objnum = in->number;
319  /* tmp.version = in->version; */
320  obj_map = (ObjMap *) avl_find(pdf_doc->ObjMapTree, &tmp);
321  return obj_map;
322 }
323 
324 static void addObjMap(PdfDocument * pdf_doc, ppref * in, int out_num)
325 {
326  ObjMap *obj_map = NULL;
327  if (pdf_doc->ObjMapTree == NULL) {
328  pdf_doc->ObjMapTree = avl_create(CompObjMap, NULL, &avl_xallocator);
329  }
330  obj_map = (ObjMap*)xmalloc(sizeof(ObjMap));
331  /* obj_map->version = in->version; */
332  obj_map->objnum = in->number;
333  obj_map->out_num = out_num;
334  avl_probe(pdf_doc->ObjMapTree, obj_map);
335 }
336 
337 /*
338  When copying the Resources of the selected page, all objects are
339  copied recursively top-down. The findObjMap() function checks if an
340  object has already been copied; if so, instead of copying just the
341  new object number will be referenced. The ObjMapTree guarantees,
342  that during the entire LuaTeX run any object from any embedded PDF
343  file will end up max. once in the output PDF file. Indirect objects
344  are not fetched during copying, but get a new object number from
345  LuaTeX and then will be appended into a linked list.
346 */
347 
349 {
350  ObjMap *obj_map;
351  InObj *p, *q, *n;
352  if (ref->number == 0) {
353  normal_error("pdf inclusion","reference to invalid object (broken pdf)");
354  }
355  if ((obj_map = findObjMap(pdf_doc, ref)) != NULL) {
356  return obj_map->out_num;
357  }
358  n = (InObj*)xmalloc(sizeof(InObj));
359  n->objnum = ref->number;
360  /* n->version = ref->version; */
361  n->next = NULL;
362  n->num = pdf_create_obj(pdf, obj_type_others, 0);
363  addObjMap(pdf_doc, ref, n->num);
364  if (pdf_doc->inObjList == NULL) {
365  pdf_doc->inObjList = n;
366  } else {
367  /*
368  It is important to add new objects at the end of the list,
369  because new objects are being added while the list is being
370  written out by writeRefs().
371  */
372  for (p = pdf_doc->inObjList; p != NULL; p = p->next)
373  q = p;
374  q->next = n;
375  }
376  return n->num;
377 }
378 
379 static void copyObject(PDF, PdfDocument *, ppobj *);
380 
381 static void copyString(PDF pdf, ppstring *str)
382 {
384  switch (ppstring_type(str)) {
385  case PPSTRING_PLAIN:
386  pdf_out(pdf, '(');
388  pdf_out(pdf, ')');
389  break;
390  case PPSTRING_BASE16:
391  pdf_out(pdf, '<');
393  pdf_out(pdf, '>');
394  break;
395  case PPSTRING_BASE85:
396  pdf_out(pdf, '<');
397  pdf_out(pdf, '~');
399  pdf_out(pdf, '~');
400  pdf_out(pdf, '>');
401  break;
402  }
404 }
405 
406 static void copyName(PDF pdf, ppname *name)
407 {
409 }
410 
412 {
413  int i;
414  int n = array->size;
416  for (i=0; i<n; ++i) {
418  }
420 }
421 
422 static void copyDict(PDF pdf, PdfDocument * pdf_doc, ppdict *dict)
423 {
424  int i;
425  int n = dict->size;
427  for (i=0; i<n; ++i) {
428  ppname *key = ppdict_key(dict,i);
430  copyObject(pdf, pdf_doc, ppdict_at(dict,i));
431  }
432  pdf_end_dict(pdf);
433 }
434 
435 static void copyStreamStream(PDF pdf, ppstream * stream, int decode, int callback_id)
436 {
437  uint8_t *data = NULL;
438  size_t size = 0;
439  if (0) {
441  pdf_out_block(pdf, (const char *) data, size);
442  }
443  } else {
445  if (data != NULL) {
446  /*tex We only do this when we recompress in which case we fetch the whole stream. */
447  if (callback_id == 1) {
449  }
450  if (callback_id) {
451  char *result = NULL;
452  run_callback(callback_id, "S->S",(char *) data,&result);
453  pdf_out_block(pdf, (const char *) (uint8_t *) result, size);
454  xfree(result);
455  } else {
456  pdf_out_block(pdf, (const char *) data, size);
457  }
458  }
459  }
461 }
462 
464 {
465  ppdict *dict = stream->dict; /* bug in: stream_dict(stream) */
466  if (pdf->compress_level == 0 || pdf->recompress) {
467  ppobj * obj = ppdict_get_obj (dict, "Filter");
468  int known = 0;
469  if (obj != NULL && obj->type == PPNAME) {
470  const char *codecs[] = {
471  "ASCIIHexDecode", "ASCII85Decode", "RunLengthDecode",
472  "FlateDecode", "LZWDecode", NULL
473  };
474  int k;
475  for (k = 0; codecs[k] != NULL; k++) {
476  if (strcmp(ppname_data(obj->name),codecs[k]) == 0) {
477  known = 1;
478  break;
479  }
480  }
481  }
482  if (known) {
483  /*tex recompress or keep uncompressed */
484  const char *ignoredkeys[] = {
485  "Filter", "DecodeParms", "Length", "DL", NULL
486  };
487  int i;
489  for (i=0; i<dict->size; ++i) {
490  ppname *key = ppdict_key(dict,i);
491  int copy = 1;
492  int k;
493  for (k = 0; ignoredkeys[k] != NULL; k++) {
494  if (strcmp(ppname_data(key),ignoredkeys[k]) == 0) {
495  copy = 0;
496  break;
497  }
498  }
499  if (copy) {
501  copyObject(pdf, pdf_doc, ppdict_at(dict,i));
502  }
503  }
505  pdf_end_dict(pdf);
507  copyStreamStream(pdf, stream, 1, 0);
509  return ;
510  }
511  }
512  /* copy as-is */
513  copyDict(pdf, pdf_doc, dict);
515  copyStreamStream(pdf, stream, 0, 0);
517 }
518 
519 static void copyObject(PDF pdf, PdfDocument * pdf_doc, ppobj * obj)
520 {
521  switch (obj->type) {
522  case PPNULL:
523  pdf_add_null(pdf);
524  break;
525  case PPBOOL:
526  pdf_add_bool(pdf,obj->integer); /* ppobj_get_bool_value(obj) */
527  break;
528  case PPINT:
529  pdf_add_int(pdf,obj->integer); /* ppobj_get_int_value(obj) */
530  break;
531  case PPNUM:
532  pdf_add_real(pdf,obj->number); /* ppobj_get_num_value(obj) */
533  break;
534  case PPNAME:
535  copyName(pdf, obj->name);
536  break;
537  case PPSTRING:
538  copyString(pdf, obj->string); /* ppobj_get_string(obj) */
539  break;
540  case PPARRAY:
541  copyArray(pdf, pdf_doc, obj->array); /* ppobj_get_array(obj) */
542  break;
543  case PPDICT:
544  copyDict(pdf, pdf_doc, obj->dict); /* ppobj_get_dict(obj) */
545  break;
546  case PPSTREAM:
547  copyStream(pdf, pdf_doc, obj->stream); /* ppobj_get_stream(obj) */
548  break;
549  case PPREF:
550  pdf_add_ref(pdf, addInObj(pdf, pdf_doc, obj->ref)); /* ppobj_get_ref(obj) */
551  break;
552  default:
553  break;
554  }
555 }
556 
558 {
559  InObj *r, *n;
560  ppobj * obj;
561  ppref * ref ;
562  ppxref * xref = ppdoc_xref (pdf_doc->pdfe);
563  for (r = pdf_doc->inObjList; r != NULL;) {
564  if (xref != NULL) {
565  ref = ppxref_find(xref, (ppuint) r->objnum);
566  if (ref != NULL) {
567  obj = ppref_obj(ref);
568  if (obj->type == PPSTREAM) {
570  } else {
571  pdf_begin_obj(pdf, r->num, 2);
572  }
573  copyObject(pdf, pdf_doc, obj);
574  pdf_end_obj(pdf);
575  } else {
576  formatted_warning("pdf inclusion","ignoring missing object %i, case 1\n",(int) r->objnum);
577  }
578  } else {
579  formatted_warning("pdf inclusion","ignoring missing object %i, case 2\n",(int) r->objnum);
580  }
581  n = r->next;
582  free(r);
583  r = n;
584  pdf_doc->inObjList = n;
585  }
586 }
587 
588 
589 /* get the pagebox coordinates according to the pagebox_spec */
590 
591 static void somebox(ppdict *page, const char * key, pprect * box)
592 {
594  if (r != NULL) {
595  box->lx = r->lx;
596  box->ly = r->ly;
597  box->rx = r->rx;
598  box->ry = r->ry;
599  }
600 }
601 
602 static void get_pagebox(ppdict * page, int pagebox_spec, pprect * box)
603 {
604  box->lx = box->rx = box->ly = box->ry = 0;
605  somebox(page,"MediaBox",box);
606  if (pagebox_spec == PDF_BOX_SPEC_MEDIA) {
607  return;
608  }
609  somebox(page,"CropBox",box);
610  if (pagebox_spec == PDF_BOX_SPEC_CROP) {
611  return;
612  }
613  switch (pagebox_spec) {
614  case PDF_BOX_SPEC_BLEED:
615  somebox(page,"BleedBox",box);
616  break;
617  case PDF_BOX_SPEC_TRIM:
618  somebox(page,"TrimBox",box);
619  break;
620  case PDF_BOX_SPEC_ART:
621  somebox(page,"ArtBox",box);
622  break;
623  default:
624  break;
625  }
626 }
627 
628 /*
629  Reads various information about the PDF and sets it up for later inclusion.
630  This will fail if the PDF version of the PDF is higher than minor_pdf_version_wanted
631  or page_name is given and can not be found. It makes no sense to give page_name and
632  page_num. Returns the page number.
633 */
634 
635 static ppdict * get_pdf_page_dict(ppdoc *pdfe, int n)
636 {
637  ppref *r;
638  int i;
639  for (r=ppdoc_first_page(pdfe), i=1; r != NULL; r = ppdoc_next_page(pdfe), ++i) {
640  if (i == n) {
641  return ppref_obj(r)->dict;
642  }
643  }
644  return NULL;
645 }
646 
648 {
650  ppdoc * pdfe = NULL;
651  ppdict *pageDict, *groupDict;
652  pprect pagebox;
653  ppint rotate = 0;
654  int pdf_major_version_found = 1;
655  int pdf_minor_version_found = 3;
656  double xsize, ysize, xorig, yorig;
657  if (img_type(idict) == IMG_TYPE_PDF) {
659  } else if (img_type(idict) == IMG_TYPE_PDFMEMSTREAM) {
661  if (pdf_doc == NULL )
662  normal_error("pdf inclusion", "memstream not initialized");
663  if (pdf_doc->pdfe == NULL)
664  normal_error("pdf inclusion", "memstream document is empty");
665  pdf_doc->occurences++;
666  } else {
667  normal_error("pdf inclusion","unknown document");
668  }
669  pdfe = pdf_doc->pdfe;
670  /*
671  Check PDF version. This works only for PDF 1.x but since any versions of
672  PDF newer than 1.x will not be backwards compatible to PDF 1.x, we will
673  then have to changed drastically anyway.
674  */
675  pdf_major_version_found = ppdoc_version_number(pdfe,&pdf_minor_version_found);
676  if ((100 * pdf_major_version_found + pdf_minor_version_found) > (100 * img_pdfmajorversion(idict) + img_pdfminorversion(idict))) {
677  const char *msg = "PDF inclusion: found PDF version '%d.%d', but at most version '%d.%d' allowed";
678  if (img_errorlevel(idict) > 0) {
679  formatted_error("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfmajorversion(idict), img_pdfminorversion(idict));
680  } else {
681  formatted_warning("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfmajorversion(idict), img_pdfminorversion(idict));
682  }
683  }
684  img_totalpages(idict) = ppdoc_page_count(pdfe);
685  if (img_pagename(idict)) {
686  /*
687  get page by name is obsolete
688  */
689  normal_error("pdf inclusion","named pages are not supported");
690  } else {
691  /*
692  get page by number
693  */
694  if (img_pagenum(idict) <= 0
695  || img_pagenum(idict) > img_totalpages(idict))
696  formatted_error("pdf inclusion","required page '%i' does not exist",(int) img_pagenum(idict));
697  }
698  /*
699  get the required page
700  */
701  pageDict = get_pdf_page_dict(pdfe,img_pagenum(idict));
702  if (pageDict==NULL) {
703  formatted_error("pdf inclusion","unable to retrive dictionary for page '%i'",(int) img_pagenum(idict));
704  }
705  /*
706  get the pagebox coordinates (media, crop,...) to use
707  */
708  get_pagebox(pageDict, img_pagebox(idict), &pagebox);
709  if (pagebox.rx > pagebox.lx) {
710  xorig = pagebox.lx;
711  xsize = pagebox.rx - pagebox.lx;
712  } else {
713  xorig = pagebox.rx;
714  xsize = pagebox.lx - pagebox.rx;
715  }
716  if (pagebox.ry > pagebox.ly) {
717  yorig = pagebox.ly;
718  ysize = pagebox.ry - pagebox.ly;
719  } else {
720  yorig = pagebox.ry;
721  ysize = pagebox.ly - pagebox.ry;
722  }
723  /*
724  The following 4 parameters are raw. Do _not_ modify by /Rotate!
725  */
726  img_xsize(idict) = bp2sp(xsize);
727  img_ysize(idict) = bp2sp(ysize);
728  img_xorig(idict) = bp2sp(xorig);
729  img_yorig(idict) = bp2sp(yorig);
730  /*
731  Handle /Rotate parameter. Only multiples of 90 deg. are allowed (PDF Ref. v1.3,
732  p. 78). We also accept negative angles. Beware: PDF counts clockwise!
733  */
734  if (ppdict_get_int(pageDict, "Rotate", &rotate)) {
735  switch ((((int)rotate % 360) + 360) % 360) {
736  case 0:
737  img_rotation(idict) = 0;
738  break;
739  case 90:
740  img_rotation(idict) = 3;
741  break;
742  case 180:
743  img_rotation(idict) = 2;
744  break;
745  case 270:
746  img_rotation(idict) = 1;
747  break;
748  default:
749  formatted_warning("pdf inclusion","/Rotate parameter in PDF file not multiple of 90 degrees");
750  }
751  }
752  /*
753  currently unused info whether PDF contains a /Group
754  */
755  groupDict = ppdict_get_dict(pageDict, "Group");
756  if (groupDict != NULL) {
757  img_set_group(idict);
758  }
759  /*
760  LuaTeX pre 0.85 versions did this:
761 
762  if (readtype == IMG_CLOSEINBETWEEN) {
763  unrefPdfDocument(img_filepath(idict));
764  }
765 
766  and also unref'd in the finalizer so we got an extra unrefs when garbage was
767  collected. However it is more efficient to keep the file open so we do that
768  now. The (slower) alternative is to unref here (which in most cases forcing a
769  close of the file) but then we must not call flush_pdf_info.
770 
771  A close (unref) can be forced by nilling the dict object at the lua end and
772  forcing a collectgarbage("collect") after that.
773 
774  */
775  if (! img_keepopen(idict)) {
777  }
778 }
779 
781 {
782  if (img_keepopen(idict)) {
784  }
785 }
786 
787 /*
788  Write the current epf_doc. Here the included PDF is copied, so most errors
789  that can happen during PDF inclusion will arise here.
790 */
791 
792 void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
793 {
795  ppdoc *pdfe = NULL;
796  ppdict *pageDict, *infoDict;
797  ppobj *obj, *content, *resources;
798  pprect pagebox;
799  int i;
800  double bbox[4];
801  const char *pagedictkeys[] = {
802  "Group", "LastModified", "Metadata", "PieceInfo", "SeparationInfo", NULL
803  };
804  /*
805  open PDF file
806  */
807  if (img_type(idict) == IMG_TYPE_PDF) {
809  } else if (img_type(idict) == IMG_TYPE_PDFMEMSTREAM) {
811  pdf_doc->occurences++;
812  } else {
813  normal_error("pdf inclusion","unknown document");
814  }
815  pdfe = pdf_doc->pdfe;
816  pageDict = get_pdf_page_dict(pdfe,img_pagenum(idict));
817  if (pageDict==NULL) {
818  formatted_error("pdf inclusion","unable to retrive dictionary for page '%i'",(int) img_pagenum(idict));
819  }
820  /*
821  write the Page header
822  */
825  pdf_dict_add_name(pdf, "Type", "XObject");
826  pdf_dict_add_name(pdf, "Subtype", "Form");
827  pdf_dict_add_int(pdf, "FormType", 1);
828  /*
829  write additional information
830  */
832  if ((suppress_optional_info & 4) == 0) {
833  pdf_dict_add_int(pdf, "PTEX.PageNumber", (int) img_pagenum(idict));
834  }
835  if ((suppress_optional_info & 8) == 0) {
836  infoDict = ppdoc_info(pdfe);
837  if (infoDict != NULL) {
838  /* todo : check this
839  pdf_dict_add_ref(pdf, "PTEX.InfoDict", addInObj(pdf, pdf_doc, infoDict));
840  */
841  pdf_add_name(pdf, "PTEX.InfoDict");
842  copyDict(pdf, pdf_doc, infoDict);
843  }
844  }
845  if (img_is_bbox(idict)) {
846  bbox[0] = sp2bp(img_bbox(idict)[0]);
847  bbox[1] = sp2bp(img_bbox(idict)[1]);
848  bbox[2] = sp2bp(img_bbox(idict)[2]);
849  bbox[3] = sp2bp(img_bbox(idict)[3]);
850  } else {
851  /*
852  get the pagebox coordinates (media, crop,...) to use.
853  */
854  get_pagebox(pageDict, img_pagebox(idict), &pagebox);
855  bbox[0] = pagebox.lx;
856  bbox[1] = pagebox.ly;
857  bbox[2] = pagebox.rx;
858  bbox[3] = pagebox.ry;
859  }
860  pdf_add_name(pdf, "BBox");
862  pdf_add_real(pdf, bbox[0]);
863  pdf_add_real(pdf, bbox[1]);
864  pdf_add_real(pdf, bbox[2]);
865  pdf_add_real(pdf, bbox[3]);
867  /*
868  Now all relevant parts of the Page dictionary are copied. Metadata validity
869  check is needed(as a stream it must be indirect).
870  */
871  obj = ppdict_get_obj(pageDict, "Metadata");
872  if (obj != NULL && obj->type != PPREF) {
873  formatted_warning("pdf inclusion","/Metadata must be indirect object");
874  }
875  /*
876  copy selected items in Page dictionary
877  */
878  for (i = 0; pagedictkeys[i] != NULL; i++) {
879  obj = ppdict_get_obj(pageDict, pagedictkeys[i]);
880  if (obj != NULL) {
881  pdf_add_name(pdf, pagedictkeys[i]);
882  /*
883  preserves indirection
884  */
885  copyObject(pdf, pdf_doc, obj);
886  }
887  }
888  resources = ppdict_rget_obj(pageDict, "Resources");
889  if (resources == NULL) {
890  /*
891  If there are no Resources in the Page dict of the embedded page,
892  try to inherit the Resources from the Pages tree of the embedded
893  PDF file, climbing up the tree until the Resources are found.
894  (This fixes a problem with Scribus 1.3.3.14.)
895  */
896  obj = ppdict_rget_obj(pageDict, "Parent");
897  while (obj != NULL && obj->type == PPDICT) {
898  resources = ppdict_rget_obj(obj->dict, "Resources");
899  if (resources != NULL) {
900  break;
901  }
902  obj = ppdict_get_obj(obj->dict, "Parent");
903  }
904  }
905  if (resources != NULL) {
906  pdf_add_name(pdf, "Resources");
908  } else {
909  formatted_warning("pdf inclusion","Page /Resources missing");
910  }
911  /*
912  User supplied entries.
913  */
914  if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) {
915  pdf_printf(pdf, "\n%s\n", img_attr(idict));
916  }
917  /*
918  Write the Page contents.
919  */
920  content = ppdict_rget_obj(pageDict, "Contents");
921  if (content && content->type == PPSTREAM) {
922  if (pdf->compress_level == 0 || pdf->recompress) {
924  pdf_end_dict(pdf);
926  copyStreamStream(pdf, content->stream, 1, 1); /* decompress */
927  } else {
928  /* copies compressed stream */
929  ppstream * stream = content->stream;
930  ppdict *streamDict = stream->dict; /* */
931  obj = ppdict_rget_obj(streamDict, "Length");
932  if (obj != NULL) {
933  pdf_add_name(pdf, "Length");
934  copyObject(pdf, pdf_doc, obj);
935  obj = ppdict_rget_obj(streamDict, "Filter");
936  if (obj != NULL) {
937  pdf_add_name(pdf, "Filter");
938  copyObject(pdf, pdf_doc, obj);
939  /* the next one is irrelevant, only for inline images: */
940  /*
941  obj = ppdict_rget_obj(streamDict, "DecodeParms");
942  if (obj != NULL) {
943  pdf_add_name(pdf, "DecodeParms");
944  copyObject(pdf, pdf_doc, obj);
945  }
946  */
947  }
948  pdf_end_dict(pdf);
950  copyStreamStream(pdf, stream, 0, 0);
951  } else {
953  pdf_end_dict(pdf);
955  copyStreamStream(pdf, stream, 1, 0);
956  }
957  }
959  } else if (content && content->type == PPARRAY) {
960  /* listens to compresslevel */
962  pdf_end_dict(pdf);
964  {
965  int i;
966  int b = 0;
967  int n = content->array->size;
968  for (i=0; i<n; ++i) {
969  ppobj *o = pparray_at(content->array,i);
970  while (o != NULL && o->type == PPREF) {
971  o = ppref_obj((ppref *) o->ref);
972  }
973  if (o != NULL && o->type == PPSTREAM) {
974  if (b) {
975  /*
976  Put a space between streams to be on the safe side (streams
977  should have a trailing space here, but one never knows)
978  */
979  pdf_out(pdf, ' ');
980  } else {
981  b = 1;
982  }
983  copyStreamStream(pdf, (ppstream *) o->stream, 1, 0);
984  }
985  }
986  }
988  } else {
989  /*
990  the contents are optional, but we need to include an empty stream
991  */
993  pdf_end_dict(pdf);
996  }
997  pdf_end_obj(pdf);
998  /*
999  write out all indirect objects
1000  */
1001  writeRefs(pdf, pdf_doc);
1002  /*
1003  unrefPdfDocument() must come after freeing whatever is used
1004 
1005  */
1006  if (! img_keepopen(idict)) {
1008  }
1009 }
1010 
1011 /* a special simple case of inclusion, e.g. an appearance stream */
1012 
1014 {
1015  int num = 0 ;
1016  if (img_type(idict) != IMG_TYPE_PDF) {
1017  normal_error("pdf inclusion","unknown document");
1018  } else {
1020  ppdoc * pdfe = pdf_doc->pdfe;
1021  if (ppdoc_xref(pdfe)) {
1022  ppref * ref = ppxref_find(ppdoc_xref(pdfe), (ppuint) n);
1023  if (ref != NULL) {
1024  ppobj *obj;
1025  num = pdf->obj_count++;
1026  obj = ppref_obj(ref);
1027  if (obj->type == PPSTREAM) {
1029  } else {
1030  pdf_begin_obj(pdf, num, 2);
1031  }
1032  copyObject(pdf, pdf_doc, obj);
1033  pdf_end_obj(pdf);
1034  writeRefs(pdf, pdf_doc);
1035  } else {
1036  formatted_warning("pdf inclusion","ignoring missing image %i, case 1\n",(int) n);
1037  }
1038  } else {
1039  formatted_warning("pdf inclusion","ignoring missing image %i, case 2\n",(int) n);
1040  }
1041  if (! img_keepopen(idict)) {
1043  }
1044  }
1045  return num;
1046 }
1047 
1048 /* Deallocate a PdfDocument with all its resources. */
1049 
1051 {
1052  InObj *r, *n;
1053  /* this may be probably needed for an emergency destroyPdfDocument() */
1054  for (r = pdf_doc->inObjList; r != NULL; r = n) {
1055  n = r->next;
1056  free(r);
1057  }
1058  if (pdf_doc->pdfe != NULL) {
1059  ppdoc_free(pdf_doc->pdfe);
1060  pdf_doc->pdfe = NULL;
1061  }
1062  if (pdf_doc->memstream != NULL) {
1063  /* pplib does this: free(pdf_doc->memstream); */
1064  pdf_doc->memstream = NULL;
1065  }
1066  /* pdf_doc->pc++; */
1067  pdf_doc->pc = 0;
1068 }
1069 
1070 static void destroyPdfDocument(void *pa, void * p)
1071 {
1072  PdfDocument *pdf_doc = (PdfDocument *) pa;
1074  /* TODO: delete rest of pdf_doc */
1075 }
1076 
1077 /*
1078  Called when an image has been written and its resources in image_tab are
1079  freed and it's not referenced anymore.
1080 */
1081 
1082 void unrefPdfDocument(char *file_path)
1083 {
1084  PdfDocument *pdf_doc = findPdfDocument(file_path);
1085  if (pdf_doc == NULL) {
1086  /* we're ok */
1087  } else if (pdf_doc->occurences > 0) {
1088  pdf_doc->occurences--;
1089  if (pdf_doc->occurences == 0) {
1091  }
1092  } else {
1093  /*
1094  We either have a mismatch in ref and unref or we're somehow out of sync
1095  which can happen when we mess with the same file in lua and tex.
1096  */
1097  formatted_warning("pdf inclusion","there can be a mismatch in opening and closing file '%s'",file_path);
1098  }
1099 }
1100 
1101 /*
1102  For completeness, but it isn't currently used (unreferencing is done by mean
1103  of file_path.
1104 */
1105 
1106 void unrefMemStreamPdfDocument(char *file_id)
1107 {
1108  (void) unrefPdfDocument(file_id);
1109 
1110 }
1111 
1112 /*
1113  Called when PDF embedding system is finalized. We now deallocate all remaining
1114  PdfDocuments.
1115 */
1116 
1117 void epdf_free(void)
1118 {
1119  if (PdfDocumentTree != NULL)
1122 }
q
Definition: afm2pl.c:2287
#define name
#define hash
Definition: aptex.h:388
int streamsize
Definition: cbstream.h:46
#define n
Definition: t4ht.c:1290
#define b
Definition: jpegint.h:372
#define free(a)
Definition: decNumber.cpp:310
int strcmp()
Definition: coll.cpp:143
char * strcpy()
struct rect data
Definition: dvipdfm.c:64
static void
Definition: fpif.c:118
static void copy(GlyphCachePtr *root)
Definition: gcache.c:378
#define a(n)
Definition: gpos-common.c:148
static void decode()
assert(pcxLoadImage24((char *)((void *) 0), fp, pinfo, hdr))
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
#define PRIu64
Definition: inttypes.h:132
unsigned char uint8_t
Definition: stdint.h:78
unsigned __int64 uint64_t
Definition: stdint.h:90
int num
Definition: disdvi.c:621
#define xstrdup(s)
Definition: writet1.c:34
#define xmalloc(size)
Definition: writet1.c:33
struct pdf_doc pdf_doc
static struct res_cache resources[(sizeof(pdf_resource_categories)/sizeof(pdf_resource_categories[0]))]
Definition: pdfresource.c:92
#define malloc
Definition: alloca.c:91
void ** avl_probe(struct avl_table *tree, void *item)
Definition: avl.c:85
struct libavl_allocator avl_xallocator
Definition: avlstuff.c:41
#define img_type(N)
Definition: image.h:89
long time_t
Definition: types.h:18
long off_t
Definition: types.h:34
int stat(const char *path, struct stat *sbuf)
int strncmp()
#define snprintf
Definition: snprintf.c:41
int run_callback(int i, const char *values,...)
Definition: lcallbacklib.c:259
void normal_error(const char *t, const char *p)
Definition: errors.c:951
void formatted_error(const char *t, const char *fmt,...)
Definition: errors.c:1038
void formatted_warning(const char *t, const char *fmt,...)
Definition: errors.c:1048
@ process_pdf_image_content_callback
#define callback_defined(a)
def ref(x)
Definition: pdf-org.py:104
Definition: pdf.py:1
int k
Definition: otp-parser.c:70
void out_num(unsigned val)
Definition: out_routines.c:293
integer checksum
Definition: pbmtopk.c:63
void pdf_printf(const char *,...)
void flush_pdf_info(image_dict *idict)
Definition: pdftoepdf.c:780
static int addInObj(PDF pdf, PdfDocument *pdf_doc, ppref *ref)
Definition: pdftoepdf.c:348
static ppdict * get_pdf_page_dict(ppdoc *pdfe, int n)
Definition: pdftoepdf.c:635
#define pdf_set_space(pdf)
Definition: pdftoepdf.c:45
static void copyObject(PDF, PdfDocument *, ppobj *)
Definition: pdftoepdf.c:519
PdfDocument * refMemStreamPdfDocument(char *docstream, unsigned long long streamsize, char *file_id)
Definition: pdftoepdf.c:229
static void copyName(PDF pdf, ppname *name)
Definition: pdftoepdf.c:406
static void deletePdfDocumentPdfDoc(PdfDocument *pdf_doc)
Definition: pdftoepdf.c:1050
void write_epdf(PDF pdf, image_dict *idict, int suppress_optional_info)
Definition: pdftoepdf.c:792
#define xfree(a)
Definition: pdftoepdf.c:30
static PdfDocument * findPdfDocument(char *file_path)
Definition: pdftoepdf.c:66
static int CompObjMap(void *pa, void *pb, void *p)
Definition: pdftoepdf.c:294
void unrefPdfDocument(char *file_path)
Definition: pdftoepdf.c:1082
static void destroyPdfDocument(void *pa, void *p)
Definition: pdftoepdf.c:1070
int write_epdf_object(PDF pdf, image_dict *idict, int n)
Definition: pdftoepdf.c:1013
#define pdf_out(pdf, A)
Definition: pdftoepdf.c:36
void read_pdf_info(image_dict *idict)
Definition: pdftoepdf.c:647
static void somebox(ppdict *page, char *key, pprect *box)
Definition: pdftoepdf.c:591
static void addObjMap(PdfDocument *pdf_doc, ppref *in, int out_num)
Definition: pdftoepdf.c:324
void epdf_free(void)
Definition: pdftoepdf.c:1117
static avl_table * PdfDocumentTree
Definition: pdftoepdf.c:55
static ObjMap * findObjMap(PdfDocument *pdf_doc, ppref *in)
Definition: pdftoepdf.c:312
void unrefMemStreamPdfDocument(char *file_id)
Definition: pdftoepdf.c:1106
static void copyString(PDF pdf, ppstring *str)
Definition: pdftoepdf.c:381
static int CompPdfDocument(void *pa, void *pb, void *p)
Definition: pdftoepdf.c:59
static char * get_file_checksum(char *a, file_error_mode fe)
Definition: pdftoepdf.c:85
#define pdf_check_space(pdf)
Definition: pdftoepdf.c:38
static void copyArray(PDF pdf, PdfDocument *pdf_doc, pparray *array)
Definition: pdftoepdf.c:411
static void copyDict(PDF pdf, PdfDocument *pdf_doc, ppdict *dict)
Definition: pdftoepdf.c:422
static void copyStream(PDF pdf, PdfDocument *pdf_doc, ppstream *stream)
Definition: pdftoepdf.c:463
static void writeRefs(PDF pdf, PdfDocument *pdf_doc)
Definition: pdftoepdf.c:557
static void copyStreamStream(PDF pdf, ppstream *stream, int decode, int callback_id)
Definition: pdftoepdf.c:435
#define PDF_CHECKSUM_SIZE
Definition: pdftoepdf.c:79
static void get_pagebox(ppdict *page, int pagebox_spec, pprect *box)
Definition: pdftoepdf.c:602
static char * get_stream_checksum(char *str, unsigned long long str_size)
Definition: pdftoepdf.c:117
PdfDocument * refPdfDocument(char *file_path, file_error_mode fe, char *userpassword, char *ownerpassword)
Definition: pdftoepdf.c:141
#define OBJSTM_NEVER
Definition: pdftypes.h:51
@ obj_type_others
Definition: pdftypes.h:221
static int cnt
Definition: pkout.c:166
static int mtime
Definition: pngtopnm.c:77
static int size
Definition: ppmlabel.c:24
int r
Definition: ppmqvga.c:68
static int ysize
Definition: ppmtopjxl.c:42
static int xsize
Definition: ppmtopjxl.c:41
bp2sp(float f)
Definition: psifont.c:135
struct stream_s stream
Definition: pts_fax.h:93
#define ppdict_key(dict, index)
Definition: ppapi.h:256
ppref * ppdoc_next_page(ppdoc *pdf)
Definition: ppload.c:2500
void ppdoc_free(ppdoc *pdf)
Definition: ppload.c:2295
ppdict * ppdict_get_dict(ppdict *dict, const char *name)
Definition: ppdict.c:130
#define ppstring_data(string)
Definition: ppapi.h:197
void ppstream_done(ppstream *stream)
Definition: ppstream.c:241
ppuint ppdoc_page_count(ppdoc *pdf)
Definition: ppload.c:2345
ppdoc * ppdoc_mem(const void *data, size_t size)
Definition: ppload.c:2287
int ppdict_get_int(ppdict *dict, const char *name, ppint *v)
Definition: ppdict.c:58
uint8_t * ppstream_all(ppstream *stream, size_t *size, int decode)
Definition: ppstream.c:229
uint8_t * ppstream_next(ppstream *stream, size_t *size)
Definition: ppstream.c:216
#define ppname_data(name)
Definition: ppapi.h:182
#define ppdoc_info(pdf)
Definition: ppapi.h:321
int64_t ppint
Definition: ppapi.h:16
#define ppstring_type(string)
Definition: ppapi.h:208
ppcrypt_status ppdoc_crypt_pass(ppdoc *pdf, const void *userpass, size_t userpasslength, const void *ownerpass, size_t ownerpasslength)
Definition: ppload.c:2174
#define PPSTRING_BASE85
Definition: ppapi.h:204
size_t ppuint
Definition: ppapi.h:17
ppdoc * ppdoc_load(const char *filename)
Definition: ppload.c:2265
#define PPSTRING_BASE16
Definition: ppapi.h:203
@ PPDICT
Definition: ppapi.h:110
@ PPREF
Definition: ppapi.h:112
@ PPSTRING
Definition: ppapi.h:108
@ PPNULL
Definition: ppapi.h:103
@ PPARRAY
Definition: ppapi.h:109
@ PPSTREAM
Definition: ppapi.h:111
@ PPNUM
Definition: ppapi.h:106
@ PPNAME
Definition: ppapi.h:107
@ PPBOOL
Definition: ppapi.h:104
#define pparray_at(array, index)
Definition: ppapi.h:221
uint8_t * ppstream_first(ppstream *stream, size_t *size, int decode)
Definition: ppstream.c:204
#define ppstring_size(string)
Definition: ppapi.h:196
ppref * ppxref_find(ppxref *xref, ppuint refnumber)
Definition: ppxref.c:158
int ppdoc_version_number(ppdoc *pdf, int *minor)
Definition: ppload.c:2741
ppref * ppdoc_first_page(ppdoc *pdf)
Definition: ppload.c:2488
#define PPSTRING_PLAIN
Definition: ppapi.h:202
ppobj * ppdict_rget_obj(ppdict *dict, const char *name)
Definition: ppdict.c:40
ppxref * ppdoc_xref(ppdoc *pdf)
Definition: ppxref.c:185
pprect * ppdict_get_box(ppdict *dict, const char *name, pprect *rect)
Definition: ppload.c:2686
ppcrypt_status ppdoc_crypt_status(ppdoc *pdf)
Definition: ppload.c:2303
#define ppref_obj(ref)
Definition: ppapi.h:299
#define ppdict_at(dict, index)
Definition: ppapi.h:255
ppobj * ppdict_get_obj(ppdict *dict, const char *name)
Definition: ppdict.c:29
#define PPINT(N)
Definition: ppconf.h:68
#define avl_find
Definition: avl.h:18
#define avl_create
Definition: avl.h:19
#define avl_destroy
Definition: avl.h:20
#define rotate(D, num)
Definition: md5.c:38
void pdf_add_name(PDF, char *name)
void pdf_add_real(PDF, double d)
Definition: pdfgen.c:2554
int pdf_create_obj(PDF pdf, int t, int i)
Definition: pdftables.c:121
void pdf_end_obj(PDF)
Definition: pdfgen.c:1277
void pdf_add_int(PDF, int i)
Definition: pdfgen.c:1183
void pdf_dict_add_int(PDF, char *key, int i)
void pdf_add_null(PDF)
Definition: pdfgen.c:1166
#define STREAM_URI_LEN
Definition: epdf.h:181
void pdf_dict_add_img_filename(PDF pdf, image_dict *idict)
Definition: writeimg.c:716
void pdf_end_stream(PDF)
Definition: pdfgen.c:631
file_error_mode
Definition: epdf.h:50
@ FE_RETURN_NULL
Definition: epdf.h:50
@ FE_FAIL
Definition: epdf.h:50
void pdf_end_dict(PDF)
Definition: pdfgen.c:1125
void pdf_end_array(PDF)
Definition: pdfgen.c:1249
void pdf_add_ref(PDF, int num)
Definition: pdfgen.c:1212
void pdf_begin_obj(PDF, int, int)
Definition: pdfgen.c:1256
void pdf_add_bool(PDF, int i)
Definition: pdfgen.c:1173
#define STREAM_URI
Definition: epdf.h:180
void pdf_begin_array(PDF)
Definition: pdfgen.c:1242
void pdf_begin_dict(PDF)
Definition: pdfgen.c:1118
void pdf_out_block(PDF pdf, char *s, size_t n)
void pdf_dict_add_streaminfo(PDF)
Definition: pdfgen.c:1227
void pdf_dict_add_name(PDF, char *key, char *val)
#define STRSTREAM_CHECKSUM_SIZE
Definition: epdf.h:178
void pdf_begin_stream(PDF)
Definition: pdfgen.c:618
#define img_pagenum(N)
Definition: image.h:164
#define img_xorig(N)
Definition: image.h:155
@ PDF_BOX_SPEC_TRIM
Definition: image.h:92
@ PDF_BOX_SPEC_BLEED
Definition: image.h:91
@ PDF_BOX_SPEC_CROP
Definition: image.h:90
@ PDF_BOX_SPEC_ART
Definition: image.h:93
@ PDF_BOX_SPEC_MEDIA
Definition: image.h:89
#define img_keepopen(N)
Definition: image.h:181
#define img_bbox(N)
Definition: image.h:177
#define sp2bp(i)
Definition: image.h:35
#define img_pdfminorversion(N)
Definition: image.h:187
#define img_pdfmajorversion(N)
Definition: image.h:186
#define img_userpassword(N)
Definition: image.h:168
#define img_errorlevel(N)
Definition: image.h:185
#define img_pagename(N)
Definition: image.h:165
#define img_set_group(N)
Definition: image.h:211
#define img_xsize(N)
Definition: image.h:153
#define img_totalpages(N)
Definition: image.h:163
#define img_attr(N)
Definition: image.h:171
#define img_ysize(N)
Definition: image.h:154
#define img_pagebox(N)
Definition: image.h:176
#define img_ownerpassword(N)
Definition: image.h:169
@ IMG_TYPE_PDF
Definition: image.h:75
@ IMG_TYPE_PDFMEMSTREAM
Definition: image.h:81
#define img_yorig(N)
Definition: image.h:156
#define img_rotation(N)
Definition: image.h:159
#define img_is_bbox(N)
Definition: image.h:209
#define img_objnum(N)
Definition: image.h:146
#define img_filepath(N)
Definition: image.h:170
#define str(s)
Definition: sh6.c:399
static FILE * in
Definition: squeeze.c:36
int objnum
Definition: pdftoepdf.c:290
int out_num
Definition: pdftoepdf.c:291
char * file_path
Definition: epdf.h:160
Definition: avl.h:61
Definition: nsfix.c:44
Definition: jquant2.c:258
Definition: utils.c:300
Definition: texview.c:48
Definition: mendex.h:14
Definition: tpic.c:45
Definition: ppapi.h:43
Definition: ppapi.h:48
size_t size
Definition: ppapi.h:51
Definition: ppload.h:28
Definition: ppapi.h:26
Definition: ppapi.h:117
ppstring * string
Definition: ppapi.h:122
ppdict * dict
Definition: ppapi.h:124
ppstream * stream
Definition: ppapi.h:125
ppobjtp type
Definition: ppapi.h:129
ppref * ref
Definition: ppapi.h:126
ppname * name
Definition: ppapi.h:121
ppint integer
Definition: ppapi.h:119
ppnum number
Definition: ppapi.h:120
pparray * array
Definition: ppapi.h:123
Definition: ppapi.h:372
ppnum ry
Definition: ppapi.h:373
ppnum ly
Definition: ppapi.h:373
ppnum rx
Definition: ppapi.h:373
ppnum lx
Definition: ppapi.h:373
Definition: ppapi.h:134
Definition: ppapi.h:73
Definition: ppapi.h:33
Definition: ppxref.h:18
*job_name strlen((char *) job_name) - 4)
#define xref
Definition: tex2xindy.c:758
#define key
Definition: tex2xindy.c:753
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
#define known
Definition: preamble.h:35
#define return(val)