1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
|
/*---------------------------------------------------------------------------*
| PDFlib - A library for generating PDF on the fly |
+---------------------------------------------------------------------------+
| Copyright (c) 1997-2006 Thomas Merz and PDFlib GmbH. All rights reserved. |
+---------------------------------------------------------------------------+
| |
| This software is subject to the PDFlib license. It is NOT in the |
| public domain. Extended versions and commercial licenses are |
| available, please check http://www.pdflib.com. |
| |
*---------------------------------------------------------------------------*/
/* $Id: p_intern.h,v 1.1 2008/10/17 06:11:49 scuri Exp $
*
* PDFlib internal definitions
*
*/
#ifndef P_INTERN_H
#define P_INTERN_H
#include "pdflib.h"
#include "ft_font.h"
#include "pc_file.h"
#include "pc_contain.h"
#include "p_keyconn.h"
/* ------------------------ PDFlib feature configuration ------------------- */
/* changing the following is not recommended, and not supported */
/* BMP image support */
/* #define PDF_BMP_SUPPORTED CDPDF: leave this to the IM library */
/* GIF image support */
/* #define PDF_GIF_SUPPORTED CDPDF: leave this to the IM library */
/* JPEG image support */
/* #define PDF_JPEG_SUPPORTED CDPDF: leave this to the IM library */
/* JPEG2000 image support */
/* #define PDF_JPX_SUPPORTED CDPDF: leave this to the IM library */
/* PNG image support, requires HAVE_LIBZ */
/* #define HAVE_LIBPNG CDPDF: leave this to the IM library */
/* TIFF image support */
/* #define HAVE_LIBTIFF CDPDF: leave this to the IM library */
/* -------------------------------- macros ------------------------------- */
/*
* Allocation chunk sizes. These don't affect the generated documents
* in any way. In order to save initial memory, however, you can lower
* the values. Increasing the values will bring some performance gain
* for large documents, but will waste memory for small ones.
*/
#define PAGES_CHUNKSIZE 512 /* pages */
#define PNODES_CHUNKSIZE 64 /* page tree nodes */
#define CONTENTS_CHUNKSIZE 64 /* page content streams */
#define FONTS_CHUNKSIZE 16 /* document fonts */
#define XOBJECTS_CHUNKSIZE 128 /* document xobjects */
#define IMAGES_CHUNKSIZE 128 /* document images */
#define OUTLINE_CHUNKSIZE 256 /* document outlines */
#define NAMES_CHUNKSIZE 256 /* names */
#define PDI_CHUNKSIZE 16 /* PDI instances */
#define COLORSPACES_CHUNKSIZE 16 /* color spaces */
#define PATTERN_CHUNKSIZE 4 /* pattern */
#define SHADINGS_CHUNKSIZE 4 /* shadings */
#define EXTGSTATE_CHUNKSIZE 4 /* external graphic states */
#define T3GLYPHS_CHUNKSIZE 256 /* type 3 font glyph table */
#define ICCPROFILE_CHUNKSIZE 4 /* ICC profiles */
#define STRINGLISTS_CHUNKSIZE 128 /* document stringlists */
#define ITEMS_CHUNKSIZE 256 /* PDFlib items */
#define ITEMS_KIDS_CHUNKSIZE 64 /* PDFlib item's kids */
#define ITEMS_MC_CHUNKSIZE 16 /* PDFlib item mc sequences */
#define LAYER_DEP_CHUNKSIZE 16 /* PDFlib layer dependencies */
#define RESLIST_CHUNKSIZE 16 /* per page resource list */
/* Acrobat 4 allows only 12 levels, but Acrobat 5 increases the limit to 28 */
#define PDF_MAX_SAVE_LEVEL 28 /* max number of save levels */
#define PDF_MAX_PARAMSTRING 256 /* image parameter string */
#define PDF_MAX_NAMESTRING 127 /* maximum name length */
#define PDF_MAX_EVENTS 16 /* maximum number of events */
#define PDF_MAX_DASHLENGTH 8 /* maximum number of dashes */
/* default PDF compatibility */
#define PDF_DEF_COMPATIBILITY PDC_1_6
/* ------------------------ typedefs and enums --------------------------- */
/* PDFlib error numbers.
*/
#ifndef P_GENERR_H
enum
{
#define pdf_genNames 1
#include "p_generr.h"
PDF_E_dummy
};
#endif
#define pdf_state_content \
(pdf_state) (pdf_state_page | pdf_state_pattern | \
pdf_state_template | pdf_state_glyph)
#define pdf_state_all \
(pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page | \
pdf_state_pattern | pdf_state_template | pdf_state_path | \
pdf_state_font | pdf_state_glyph)
#define PDF_STATE_STACK_SIZE 4
/* function-like macros.
** must behave well wherever function calls are syntactically legal.
*/
#define PDF_GET_STATE(p) \
((p)->state_stack[(p)->state_sp])
#define PDF_SET_STATE(p, s) \
((p)->state_stack[(p)->state_sp] = (s))
/* statement-like macros.
** must behave well wherever statements are syntactically legal.
*/
#define PDF_CHECK_STATE(p, s) \
if ((((p)->state_stack[(p)->state_sp] & (s)) != 0)) { \
} else pdc_error((p)->pdc, \
PDF_E_DOC_SCOPE, pdf_current_scope(p), 0, 0, 0)
#define PDF_PUSH_STATE(p, fn, s) \
if ((p)->state_sp == PDF_STATE_STACK_SIZE - 1) \
pdc_error((p)->pdc, PDF_E_INT_SSTACK_OVER, fn, 0, 0, 0); \
else \
(p)->state_stack[++(p)->state_sp] = (s)
#define PDF_POP_STATE(p, fn) \
if ((p)->state_sp == 0) \
pdc_error((p)->pdc, PDF_E_INT_SSTACK_UNDER, fn, 0, 0, 0); \
else \
--(p)->state_sp
/* -------------------------- structs ------------------------------ */
#ifndef PDI_DEFINED
#define PDI_DEFINED
typedef struct PDI_s PDI; /* The opaque PDI type */
typedef struct pdi_pcos_s pdi_pcos;
typedef struct pdi_props_s pdi_props;
#endif
typedef struct
{
pdc_bool info_mode;
PDI * pi;
pdc_byte * data;
pdi_pcos * pcc;
} pdf_pdi;
/* Opaque types which are detailed in the respective modules
in alphabetical order */
typedef struct pdf_category_s pdf_category;
typedef struct pdf_colorspace_s pdf_colorspace;
typedef struct pdf_cstate_s pdf_cstate;
typedef struct pdf_dest_s pdf_dest;
typedef struct pdf_document_s pdf_document;
typedef struct pdf_extgstateresource_s pdf_extgstateresource;
typedef struct pdf_font_options_s pdf_font_options;
typedef struct pdf_font_s pdf_font;
typedef struct pdf_formfields_s pdf_formfields;
typedef struct pdf_iccprofile_s pdf_iccprofile;
typedef struct pdf_image_s pdf_image;
typedef struct pdf_info_s pdf_info;
typedef struct pdf_layers_s pdf_layers;
typedef struct pdf_linearopts_s pdf_linearopts;
typedef struct pdf_mbox_s pdf_mbox;
typedef struct pdf_name_s pdf_name;
typedef struct pdf_outline_s pdf_outline;
typedef struct pdf_pages_s pdf_pages;
typedef struct pdf_pattern_s pdf_pattern;
typedef struct pdf_reslist_s pdf_reslist;
typedef struct pdf_shading_s pdf_shading;
typedef struct pdf_t3font_s pdf_t3font;
typedef struct pdf_tags_s pdf_tags;
typedef struct pdf_text_options_s pdf_text_options;
typedef struct pdf_tstate_s pdf_tstate;
typedef struct pdf_widget_s pdf_widget;
typedef struct pdf_xobject_s pdf_xobject;
/* -------------------- special graphics state -------------------- */
typedef struct {
pdc_matrix ctm; /* current transformation matrix */
pdc_scalar x; /* current x coordinate */
pdc_scalar y; /* current y coordinate */
pdc_scalar startx; /* starting x point of the subpath */
pdc_scalar starty; /* starting y point of the subpath */
pdc_scalar lwidth; /* line width */
int lcap; /* line cap style */
int ljoin; /* line join style */
pdc_scalar miter; /* miter limit */
pdc_scalar flatness; /* path flatness */
pdc_bool dashed; /* line dashing in effect */
} pdf_gstate;
/* ---------------------- page/pattern/template ----------------------- */
typedef struct
{
/* graphics, text, and color state.
*/
int sl; /* current save level */
pdf_gstate gstate[PDF_MAX_SAVE_LEVEL]; /* graphics state */
pdf_tstate *tstate; /* text state */
pdf_cstate *cstate; /* color state */
pdf_text_options *currto; /* current text options */
pdf_fillrule fillrule; /* nonzero or evenodd fill rule */
pdc_vtr * mboxes; /* matchbox chain */
/* in update mode, the resource numbers generally don't start
** with 0, but with a bias value derived from the original
** page's resources.
*/
int cs_bias; /* colorspaces */
int eg_bias; /* extended gstates */
int fn_bias; /* fonts */
int pt_bias; /* patterns */
int sh_bias; /* shadings */
int xo_bias; /* xobjects */
} pdf_ppt;
/* Force graphics or color operator output, avoiding the optimization
* which checks whether the new value might be the same as the old.
* This is especially required for Type 3 glyph descriptions which
* inherit the surrounding page description's gstate parameters,
* and therefore even must write default values.
*/
#define PDF_FORCE_OUTPUT() (PDF_GET_STATE(p) == pdf_state_glyph)
/*
* *************************************************************************
* The core PDF context descriptor
* *************************************************************************
*/
struct PDF_s {
/* -------------------------- general stuff ------------------------ */
unsigned long magic; /* poor man's integrity check */
void (*freeproc)(PDF *p, void *mem);
pdc_core *pdc; /* core context */
int compatibility; /* PDF version number * 10 */
pdf_errpol errorpolicy; /* error policy */
pdf_state state_stack[PDF_STATE_STACK_SIZE];
int state_sp; /* state stack pointer */
/* ------------------- PDF Catalog dictionary --------------------- */
pdf_document *document; /* document struct */
/* ------------------- PDF Info dictionary entries ----------------- */
pdf_info *userinfo; /* list of user-defined entries */
/* -------------- I/O, error handling and memory management ------------- */
size_t (*writeproc)(PDF *p, void *data, size_t size);
void (*errorhandler)(PDF *p, int level, const char* msg);
void *opaque; /* user-specific, opaque data */
/* ------------------------- PDF import ---------------------------- */
pdf_pdi *pdi; /* PDI context array */
int pdi_capacity; /* currently allocated size */
pdc_pagebox pdi_usebox;
pdc_bool pdi_strict; /* strict PDF parser mode */
pdc_bstr * pdi_parmbuf; /* string buffer for pdi parms */
/* ------------ stuff for hypertext functions ---------- */
pdc_encoding hypertextencoding; /* encoding of hypertexts */
pdc_text_format hypertextformat; /* format of hypertexts */
int hypertextcodepage; /* OEM multi byte code-page number */
pdc_bool usercoordinates; /* interprete rectangle coordinates */
/* of hypertext funcs. in user space */
pdc_bool usehyptxtenc; /* use hypertextencoding */
/* for name strings */
/* ------------------- PDF output bookkeeping ------------------- */
pdc_id procset_id; /* id of constant ProcSet array */
pdc_output *out; /* output manager */
pdc_id length_id; /* id of current stream's length*/
pdc_flush_state flush; /* flush state */
/* ------------------- page bookkeeping ------------------- */
pdf_pages *doc_pages; /* document wide page management */
/* ------------------- document resources ------------------- */
pdf_font *fonts; /* all fonts in document */
int fonts_capacity; /* currently allocated size */
int fonts_number; /* next available font number */
int t3slot; /* slot of temporary type 3 font */
fnt_cmap_stack *cmst; /* CMap stack handle */
pdf_xobject *xobjects; /* all xobjects in document */
int xobjects_capacity; /* currently allocated size */
int xobjects_number; /* next available xobject slot */
pdf_colorspace *colorspaces; /* all color space resources */
int colorspaces_capacity; /* currently allocated size */
int colorspaces_number; /* next available color space number */
pdf_pattern *pattern; /* all pattern resources */
int pattern_capacity; /* currently allocated size */
int pattern_number; /* next available pattern number */
pdf_shading *shadings; /* all shading resources */
int shadings_capacity; /* currently allocated size */
int shadings_number; /* next available shading number */
pdf_extgstateresource *extgstates; /* all ext. graphic state resources */
int extgstates_capacity; /* currently allocated size */
int extgstates_number; /* next available extgstate number */
pdf_image *images; /* all images in document */
int images_capacity; /* currently allocated size */
pdc_vtr *actions; /* all actions in document */
/* ------------------ utilities ------------------- */
char ***stringlists; /* string lists */
int stringlists_capacity; /* currently allocated size */
int stringlists_number; /* next available string list number */
int *stringlistsizes; /* sizes of string lists */
int utilstrlist_index; /* index of utility string list */
int utilstring_number; /* next available utility string */
/* ------------------- document outline tree ------------------- */
pdf_outline *outlines; /* dynamic array of outlines */
int outline_capacity; /* currently allocated size */
int outline_count; /* total number of outlines */
/* ------------------- name tree ------------------- */
pdf_name *names; /* page ids */
int names_capacity;
int names_number; /* next available names number */
/* -------------- page/pattern/template specific stuff -------------- */
pdf_ppt * curr_ppt; /* current ppt descriptor */
pdc_id res_id; /* id of this pattern/templ res dict */
pdc_scalar ydirection; /* direction of y axis of default */
/* system rel. to viewport (1 or -1) */
pdf_renderingintent rendintent; /* RenderingIntent */
pdc_bool preserveoldpantonenames;/* preserve old PANTONE names */
pdc_bool spotcolorlookup; /* use internal look-up table for
* color values */
/* ------------------------ template stuff ----------------------- */
int templ; /* current template if in templ. state*/
/* --------------- other font and text stuff ---------------- */
pdf_font_options *currfo; /* current font settings */
pdc_glyphcheck glyphcheck; /* check for unavailable glyphs */
pdc_text_format textformat; /* text storage format */
pdc_bool in_text; /* currently in BT/ET section */
/* ------------------------ miscellaneous ------------------------ */
char debug[256]; /* debug flags */
/* ------- deprecated stuff because of deprecated parameter ---------- */
pdf_borderstyle border_style;
pdc_scalar border_width;
pdc_scalar border_red;
pdc_scalar border_green;
pdc_scalar border_blue;
pdc_scalar border_dash1;
pdc_scalar border_dash2;
pdf_dest *bookmark_dest;
char *launchlink_parameters;
char *launchlink_operation;
char *launchlink_defaultdir;
};
/* Data source for images, compression, ASCII encoding, fonts, etc. */
typedef struct PDF_data_source_s PDF_data_source;
struct PDF_data_source_s {
pdc_byte *next_byte;
size_t bytes_available;
void (*init)(PDF *, PDF_data_source *src);
int (*fill)(PDF *, PDF_data_source *src);
void (*terminate)(PDF *, PDF_data_source *src);
pdc_byte *buffer_start;
size_t buffer_length;
void *private_data;
long offset; /* start of data to read */
long length; /* length of data to read */
long total; /* total bytes read so far */
};
/* ------ Private functions for library-internal use only --------- */
/*
(((((OpenVMS porting note)))))
Symbols are restricted to <= 31 bytes on OpenVMS systems....
Please truncate new function names to fit this silly restriction!
(((((OpenVMS porting note)))))
*/
/**********************
*
* p_actions.c
*
**********************/
int pdf__create_action(PDF *p, const char *type, const char *optlist);
void pdf_delete_actions(PDF *p);
int pdf_get_max_action(PDF *p);
pdc_bool pdf_parse_and_write_actionlist(PDF *p, pdf_event_object eventobj,
pdc_id *act_idlist, const char *optlist);
pdc_bool pdf_write_action_entries(PDF *p, pdf_event_object eventobj,
pdc_id *act_idlist);
/**********************
*
* p_annots.c
*
**********************/
void pdf__add_launchlink(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *filename);
void pdf__add_locallink(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, int page, const char *optlist);
void pdf__add_note(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *contents, int len_cont,
const char *title, int len_title, const char *icon, int kopen);
void pdf__add_pdflink(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *filename, int page,
const char *optlist);
void pdf__add_weblink(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *url);
void pdf__attach_file(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *filename, int len_filename,
const char *description, int len_descr, const char *author,
int len_auth, const char *mimetype, const char *icon);
void pdf__create_annotation(PDF *p, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *type, const char *optlist);
void pdf__set_border_color(PDF *p, pdc_scalar red, pdc_scalar green,
pdc_scalar blue);
void pdf__set_border_dash(PDF *p, pdc_scalar b, pdc_scalar w);
void pdf__set_border_style(PDF *p, const char *style, pdc_scalar width);
void pdf_init_annot_params(PDF *p);
void pdf_cleanup_annot_params(PDF *p);
pdc_id pdf_write_annots_root(PDF *p, pdc_vtr *annots, pdf_widget *widgetlist);
void pdf_write_page_annots(PDF *p, pdc_vtr *annots);
void pdf_create_link(PDF *p, const char *type, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury, const char *annopts,
const char *utext, int len);
/**********************
*
* p_color.c
*
**********************/
void pdf__setcolor(PDF *p, const char *fstype, const char *colorspace,
pdc_scalar c1, pdc_scalar c2, pdc_scalar c3, pdc_scalar c4);
void pdf_init_cstate(PDF *p);
void pdf_save_cstate(PDF *p);
void pdf_cleanup_page_cstate(PDF *p, pdf_ppt *ppt);
void pdf_init_colorspaces(PDF *p);
void pdf_set_default_color(PDF *p, pdc_bool reset);
void pdf_write_page_colorspaces(PDF *p);
void pdf_mark_page_colorspace(PDF *p, int n);
void pdf_write_doc_colorspaces(PDF *p);
void pdf_write_colorspace(PDF *p, int slot, pdc_bool direct);
void pdf_cleanup_colorspaces(PDF *p);
void pdf_write_colormap(PDF *p, int slot);
/**********************
*
* p_document.c
*
**********************/
int pdf__begin_document(PDF *p, const char *filename, int len,
const char *optlist);
void pdf__begin_document_callback(PDF *p, writeproc_t writeproc,
const char *optlist);
void pdf__end_document(PDF *p, const char *optlist);
void pdf_cleanup_document(PDF *p);
void pdf_fix_openmode(PDF *p);
void pdf_insert_name(PDF *p, const char *name, pdf_nametree_type type,
pdc_id obj_id);
pdc_id pdf_get_id_from_nametree(PDF *p, pdf_nametree_type type,
const char *name);
char *pdf_parse_and_write_metadata(PDF *p, const char *optlist, pdc_bool output,
int *outlen);
pdc_off_t pdf_check_file(PDF *p, const char *filename, pdc_bool verbose);
void pdf_embed_file(PDF *p, pdc_id obj_id, const char *filename,
const char *mimetype, pdc_off_t filesize);
/* deprecated functions: */
void pdf_set_flush(PDF *p, const char *flush);
void pdf_set_uri(PDF *p, const char *uri);
void pdf_set_compatibility(PDF *p, const char *compatibility);
void pdf_set_openmode(PDF *p, const char *openmode);
void pdf_set_openaction(PDF *p, const char *openaction);
void pdf_set_viewerpreference(PDF *p, const char *viewerpreference);
const char *pdf__get_buffer(PDF *p, long *size);
/**********************
*
* p_draw.c
*
**********************/
void pdf__arc(PDF *p, pdc_scalar x, pdc_scalar y,
pdc_scalar r, pdc_scalar alpha, pdc_scalar beta);
void pdf__arcn(PDF *p, pdc_scalar x, pdc_scalar y,
pdc_scalar r, pdc_scalar alpha, pdc_scalar beta);
void pdf__circle(PDF *p, pdc_scalar x, pdc_scalar y, pdc_scalar r);
void pdf__clip(PDF *p);
void pdf__closepath(PDF *p);
void pdf__closepath_fill_stroke(PDF *p);
void pdf__closepath_stroke(PDF *p);
void pdf__curveto(PDF *p, pdc_scalar x_1, pdc_scalar y_1,
pdc_scalar x_2, pdc_scalar y_2, pdc_scalar x_3, pdc_scalar y_3);
void pdf__endpath(PDF *p);
void pdf__fill(PDF *p);
void pdf__fill_stroke(PDF *p);
void pdf__lineto(PDF *p, pdc_scalar x, pdc_scalar y);
void pdf__rlineto(PDF *p, pdc_scalar x, pdc_scalar y);
void pdf__moveto(PDF *p, pdc_scalar x, pdc_scalar y);
void pdf__rcurveto(PDF *p, pdc_scalar x_1, pdc_scalar y_1,
pdc_scalar x_2, pdc_scalar y_2, pdc_scalar x_3, pdc_scalar y_3);
void pdf__rect(PDF *p, pdc_scalar x, pdc_scalar y,
pdc_scalar width, pdc_scalar height);
void pdf__rmoveto(PDF *p, pdc_scalar x, pdc_scalar y);
void pdf__stroke(PDF *p);
void pdf_rrcurveto(PDF *p, pdc_scalar x_1, pdc_scalar y_1,
pdc_scalar x_2, pdc_scalar y_2, pdc_scalar x_3, pdc_scalar y_3);
void pdf_hvcurveto(PDF *p, pdc_scalar x_1, pdc_scalar x_2,
pdc_scalar y_2, pdc_scalar y_3);
void pdf_vhcurveto(PDF *p, pdc_scalar y_1, pdc_scalar x_2,
pdc_scalar y_2, pdc_scalar x_3);
/**********************
*
* p_encoding.c
*
**********************/
void pdf__encoding_set_char(PDF *p, const char *encoding, int slot,
const char *glyphname, int uv);
pdc_encoding pdf_get_hypertextencoding_param(PDF *p, int *codepage);
pdc_encoding pdf_get_hypertextencoding(PDF *p, const char *encoding,
int *codepage, pdc_bool verbose);
/**********************
*
* p_filter.c
*
**********************/
int pdf_data_source_buf_fill(PDF *p, PDF_data_source *src);
void pdf_data_source_file_init(PDF *p, PDF_data_source *src);
int pdf_data_source_file_fill(PDF *p, PDF_data_source *src);
void pdf_data_source_file_terminate(PDF *p, PDF_data_source *src);
void pdf_copy_stream(PDF *p, PDF_data_source *src, pdc_bool compress);
/**********************
*
* p_font.c
*
**********************/
double pdf__info_font(PDF *p, int ifont, const char *keyword,
const char *optlist);
int pdf__load_font(PDF *p, const char *fontname, int len,
const char *encoding, const char *optlist);
void pdf_init_font_options(PDF *p, pdf_font_options *fo);
void pdf_cleanup_font_curroptions(PDF *p);
void pdf_cleanup_font_options(PDF *p, pdf_font_options *fo);
void pdf_init_font(PDF *p, pdf_font *font, pdf_font_options *fo);
void pdf_cleanup_font(PDF *p, pdf_font *font);
void pdf_init_fonts(PDF *p);
void pdf_cleanup_fonts(PDF *p);
int pdf_insert_font(PDF *p, pdf_font *font);
void pdf_write_doc_fonts(PDF *p);
void pdf_write_page_fonts(PDF *p);
void pdf_get_page_fonts(PDF *p, pdf_reslist *rl);
void pdf_mark_page_font(PDF *p, int ft);
/**********************
*
* p_gstate.c
*
**********************/
void pdf__concat(PDF *p, pdc_scalar a, pdc_scalar b, pdc_scalar c, pdc_scalar d,
pdc_scalar e, pdc_scalar f);
void pdf__initgraphics(PDF *p);
void pdf__restore(PDF *p);
void pdf__rotate(PDF *p, pdc_scalar phi);
void pdf__save(PDF *p);
void pdf__scale(PDF *p, pdc_scalar sx, pdc_scalar sy);
void pdf__setdash(PDF *p, pdc_scalar b, pdc_scalar w);
void pdf__setdashpattern(PDF *p, const char *optlist);
void pdf__setflat(PDF *p, pdc_scalar flatness);
void pdf__setlinecap(PDF *p, int linecap);
void pdf__setlinejoin(PDF *p, int linejoin);
void pdf__setlinewidth(PDF *p, pdc_scalar width);
void pdf__setmatrix(PDF *p, pdc_scalar a, pdc_scalar b, pdc_scalar c,
pdc_scalar d, pdc_scalar e, pdc_scalar f);
void pdf__setmiterlimit(PDF *p, pdc_scalar miter);
void pdf__skew(PDF *p, pdc_scalar alpha, pdc_scalar beta);
void pdf__translate(PDF *p, pdc_scalar tx, pdc_scalar ty);
void pdf_setmatrix_e(PDF *p, pdc_matrix *n);
void pdf_init_gstate(PDF *p);
void pdf_concat_raw(PDF *p, pdc_matrix *m);
void pdf_reset_gstate(PDF *p);
void pdf_set_topdownsystem(PDF *p, pdc_scalar height);
void pdf_setdashpattern_internal(PDF *p, pdc_scalar *darray, int length,
pdc_scalar phase);
/**********************
*
* p_hyper.c
*
**********************/
int pdf__add_bookmark(PDF *p, const char *text, int len, int parent, int open);
void pdf__add_nameddest(PDF *p, const char *name, int len, const char *optlist);
int pdf__create_bookmark(PDF *p, const char *text, int len,
const char *optlist);
void pdf__set_info(PDF *p, const char *key, const char *value, int len);
pdf_dest *pdf_init_destination(PDF *p);
pdf_dest *pdf_parse_destination_optlist(PDF *p, const char *optlist,
int page, pdf_destuse destuse);
void pdf_cleanup_destination(PDF *p, pdf_dest *dest);
void pdf_write_destination(PDF *p, pdf_dest *dest);
pdf_dest *pdf_get_option_destname(PDF *p, pdc_resopt *resopts,
pdc_encoding hypertextencoding, int hypertextcodepage);
void pdf_init_outlines(PDF *p);
void pdf_write_outlines(PDF *p);
void pdf_write_outline_root(PDF *p);
void pdf_cleanup_outlines(PDF *p);
void pdf_feed_digest_info(PDF *p);
pdc_id pdf_write_info(PDF *p, pdc_bool moddate);
void pdf_cleanup_info(PDF *p);
/**********************
*
* p_image.c
*
**********************/
void pdf__add_thumbnail(PDF *p, int image);
void pdf__close_image(PDF *p, int image);
void pdf__fit_image(PDF *p, int image, pdc_scalar x, pdc_scalar y,
const char *optlist);
int pdf__load_image(PDF *p, const char *imagetype, const char *filename,
const char *optlist);
void pdf_grow_images(PDF *p);
void pdf_put_image(PDF *p, int im, pdc_bool firststrip,
pdc_bool checkcontentstream);
void pdf_put_inline_image(PDF *p, int im);
void pdf_init_images(PDF *p);
void pdf_cleanup_images(PDF *p);
void pdf_cleanup_image(PDF *p, int im);
void pdf_get_image_size(PDF *p, int im, pdc_scalar *width, pdc_scalar *height);
void pdf_get_image_resolution(PDF *p, int im, pdc_scalar *dpi_x,
pdc_scalar *dpi_y);
/**********************
*
* p_mbox.c
*
**********************/
double pdf__info_matchbox(PDF *p, const char *boxname, int len, int num,
const char *keyword);
pdc_vtr *pdf_new_mboxes(PDF *p, pdf_mbox *mbox, pdc_vtr *mboxes);
pdf_mbox *pdf_parse_mbox_optlist(PDF *p, const char *optlist);
pdf_mbox *pdf_get_mbox(PDF *p, pdc_vtr *mboxes, const char *name, int number,
int *o_count);
void pdf_delete_mbox(PDF *p, pdf_mbox *mbox);
void pdf_add_page_mbox(PDF *p, pdf_mbox *mbox);
pdc_bool pdf_get_mbox_drawborder(PDF *p, pdf_mbox *mbox, int keycode);
void pdf_set_mbox_rectangle(PDF *p, pdf_mbox *mbox, pdc_rectangle *rect,
int flags);
void pdf_get_mbox_rectangle(PDF *p, pdf_mbox *mbox, pdc_vector *polyline);
void pdf_draw_mbox_rectangle(PDF *p, pdf_mbox *mbox, pdc_bool saverestore);
const char *pdf_get_usematchbox(PDF *p, const char *option, const char *optval,
int *istart, int *istop);
void pdf_set_position_values(PDF *p, pdc_scalar *i_position, int nv);
/**********************
*
* p_object.c
*
**********************/
void pdf__delete(PDF *p);
PDF *pdf__new(errorproc_t errorhandler, allocproc_t allocproc,
reallocproc_t reallocproc, freeproc_t freeproc, void *opaque);
const char *pdf_current_scope(PDF *p);
/**********************
*
* p_page.c
*
**********************/
void pdf__begin_page(PDF *p, pdc_scalar width, pdc_scalar height);
void pdf__begin_page_ext(PDF *p, pdc_scalar width, pdc_scalar height,
const char *optlist);
void pdf__end_page_ext(PDF *p, const char *optlist);
void pdf__resume_page(PDF *p, const char *optlist);
void pdf__suspend_page(PDF *p, const char *optlist);
void pdf_pg_resume(PDF *p, int pageno);
void pdf_pg_suspend(PDF *p);
void pdf_init_pages(PDF *p, const char **groups, int n_groups);
void pdf_init_pages2(PDF *p);
void pdf_check_suspended_pages(PDF *p);
void pdf_cleanup_pages(PDF *p);
pdc_id pdf_get_page_id(PDF *p, int n);
int pdf_current_page(PDF *p);
int pdf_current_page_id(PDF *p);
int pdf_last_page(PDF *p);
int pdf_search_page_fwd(PDF *p, int start_page, pdc_id id);
int pdf_search_page_bwd(PDF *p, int start_page, pdc_id id);
int pdf_xlat_pageno(PDF *p, int pageno, const char *groupname);
double pdf_get_pageheight(PDF *p);
const pdc_rectangle *pdf_get_pagebox(PDF *p, pdf_pagebox box);
void pdf_set_pagebox_llx(PDF *p, pdf_pagebox box, pdc_scalar llx);
void pdf_set_pagebox_lly(PDF *p, pdf_pagebox box, pdc_scalar lly);
void pdf_set_pagebox_urx(PDF *p, pdf_pagebox box, pdc_scalar urx);
void pdf_set_pagebox_ury(PDF *p, pdf_pagebox box, pdc_scalar ury);
void pdf_set_pagebox(PDF *p, pdf_pagebox box, pdc_scalar llx, pdc_scalar lly,
pdc_scalar urx, pdc_scalar ury);
pdc_vtr *pdf_get_annots_list(PDF *p);
void pdf_set_annots_list(PDF *p, pdc_vtr *annots);
pdc_id pdf_get_thumb_id(PDF *p);
void pdf_set_thumb_id(PDF *p, pdc_id id);
void pdf_begin_contents_section(PDF *p);
void pdf_end_contents_section(PDF *p);
void pdf_add_reslist(PDF *p, pdf_reslist *rl, int num);
pdc_id pdf_write_pagelabels(PDF *p);
/**********************
*
* p_parameter.c
*
**********************/
const char *pdf__get_parameter(PDF *p, const char *key, double modifier);
double pdf__get_value(PDF *p, const char *key, double modifier);
void pdf__set_parameter(PDF *p, const char *key, const char *value);
void pdf__set_value(PDF *p, const char *key, double value);
/**********************
*
* p_pattern.c
*
**********************/
int pdf__begin_pattern(PDF *p,
pdc_scalar width, pdc_scalar height, pdc_scalar xstep, pdc_scalar ystep,
int painttype);
void pdf__end_pattern(PDF *p);
void pdf_init_pattern(PDF *p);
void pdf_write_page_pattern(PDF *p);
void pdf_get_page_patterns(PDF *p, pdf_reslist *rl);
void pdf_mark_page_pattern(PDF *p, int n);
void pdf_cleanup_pattern(PDF *p);
void pdf_grow_pattern(PDF *p);
/**********************
*
* p_shading.c
*
**********************/
int pdf__shading(PDF *p, const char *shtype, pdc_scalar x_0, pdc_scalar y_0,
pdc_scalar x_1, pdc_scalar y_1, pdc_scalar c_1, pdc_scalar c_2,
pdc_scalar c_3, pdc_scalar c_4, const char *optlist);
int pdf__shading_pattern(PDF *p, int shading, const char *optlist);
void pdf__shfill(PDF *p, int shading);
void pdf_init_shadings(PDF *p);
void pdf_write_page_shadings(PDF *p);
void pdf_get_page_shadings(PDF *p, pdf_reslist *rl);
void pdf_mark_page_shading(PDF *p, int n);
void pdf_cleanup_shadings(PDF *p);
int pdf_get_shading_painttype(PDF *p);
/**********************
*
* p_template.c
*
**********************/
int pdf__begin_template(PDF *p, pdc_scalar width, pdc_scalar height,
const char *optlist);
void pdf__end_template(PDF *p);
int pdf_embed_image(PDF *p, int im);
/**********************
*
* p_text.c
*
**********************/
void pdf__fit_textline(PDF *p, const char *text, int len,
pdc_scalar x, pdc_scalar y, const char *optlist);
double pdf__info_textline(PDF *p, const char *text, int len,
const char *keyword, const char *optlist);
void pdf__setfont(PDF *p, int font, pdc_scalar fontsize);
void pdf__set_text_pos(PDF *p, pdc_scalar x, pdc_scalar y);
void pdf__show_text(PDF *p, const char *text, int len, pdc_bool cont);
void pdf__xshow(PDF *p, const char *text, int len,
const pdc_scalar *xadvancelist);
int pdf__show_boxed(PDF *p, const char *text, int len,
pdc_scalar left, pdc_scalar top, pdc_scalar width, pdc_scalar height,
const char *hmode, const char *feature);
pdc_scalar pdf__stringwidth(PDF *p, const char *text, int len,
int font, pdc_scalar size);
void pdf_init_tstate(PDF *p);
void pdf_cleanup_page_tstate(PDF *p, pdf_ppt *ppt);
void pdf_save_tstate(PDF *p);
void pdf_restore_currto(PDF *p);
void pdf_set_tstate(PDF *p, pdc_scalar value, pdf_text_optflags flag);
double pdf_get_tstate(PDF *p, pdf_text_optflags tflag);
void pdf_end_text(PDF *p);
void pdf_reset_tstate(PDF *p);
int pdf_get_font(PDF *p);
void pdf_put_fieldtext(PDF *p, const char *text, int font);
int pdf_get_fontsize_option(PDF *p, int font, pdc_resopt *resopts,
pdc_scalar *fontsize);
/**********************
*
* p_type3.c
*
**********************/
void pdf__begin_font(PDF *p, const char *fontname, int len,
pdc_scalar a, pdc_scalar b, pdc_scalar c, pdc_scalar d,
pdc_scalar e, pdc_scalar f, const char *optlist);
void pdf__begin_glyph(PDF *p, const char *glyphname, pdc_scalar wx,
pdc_scalar llx, pdc_scalar lly, pdc_scalar urx, pdc_scalar ury);
void pdf__end_font(PDF *p);
void pdf__end_glyph(PDF *p);
int pdf_get_t3colorized(PDF *p);
/**********************
*
* p_util.c
*
**********************/
const char *pdf__utf32_to_utf16(PDF *p, const char *utf32string, int len,
const char *ordering, int *outlen);
const char *pdf__utf16_to_utf8(PDF *p, const char *utf16string, int len,
int *outlen);
const char *pdf__utf8_to_utf16(PDF *p, const char *utf8string,
const char *ordering, int *outlen);
void pdf_check_textformat(PDF *p, pdc_text_format textformat);
void pdf_check_hypertextformat(PDF *p, pdc_text_format hypertextformat);
void pdf_check_hypertextencoding(PDF *p, pdc_encoding hypertextencoding);
void pdf_put_pdfname(PDF *p, const char *name);
pdc_encoding pdf_get_hypertextencoding_opt(PDF *p, pdc_resopt *resopts,
int *codepage, pdc_bool verbose);
char *pdf_convert_hypertext_depr(PDF *p, const char *text, int len);
char *pdf_convert_hypertext(PDF *p, const char *text, int len,
pdc_text_format hypertextformat, pdc_encoding hypertextencoding,
int codepage, int *outlen, pdc_bool oututf8, pdc_bool verbose);
void pdf_put_hypertext(PDF *p, const char *text);
char *pdf_convert_name(PDF *p, const char *name, int len, int flags);
const char *pdf_convert_filename(PDF *p, const char *filename, int len,
const char *paramname, int flags);
void pdf_add_resource(PDF *p, const char *category, const char *resname);
void pdf_put_pdffilename(PDF *p, const char *text);
void pdf_check_handle(PDF *p, int value, pdc_opttype type);
void pdf_set_clientdata(PDF *p, pdc_clientdata *clientdata);
void pdf_init_stringlists(PDF *p);
int pdf_insert_stringlist(PDF *p, char **stringlist, int ns);
void pdf_cleanup_stringlists(PDF *p);
int pdf_insert_utilstring(PDF *p, const char *utilstring, pdc_bool kdup);
const char *pdf_get_utilstring(PDF *p, int i);
int pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts,
pdc_encoding enc, int codepage, pdc_bool ishypertext,
const char *fieldname, char **text, char ***textlist);
char *pdf_get_opt_utf8name(PDF *p, const char *keyword, pdc_resopt *resopts);
pdc_bool pdf_get_errorpolicy(PDF *p, pdc_resopt *resopts, pdc_bool verbose);
/**********************
*
* p_xgstate.c
*
**********************/
int pdf__create_gstate(PDF *p, const char *optlist);
void pdf__set_gstate(PDF *p, int gstate);
void pdf_init_extgstates(PDF *p);
void pdf_write_page_extgstates(PDF *p);
void pdf_get_page_extgstates(PDF *p, pdf_reslist *rl);
void pdf_mark_page_extgstate(PDF *p, int n);
void pdf_write_doc_extgstates(PDF *p);
void pdf_cleanup_extgstates(PDF *p);
pdc_id pdf_get_gstate_id(PDF *p, int gstate);
#endif /* P_INTERN_H */
|