1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
15
/* Internal definitions for PDF-writing driver. */
17
#ifndef gdevpdfx_INCLUDED
18
# define gdevpdfx_INCLUDED
31
#define FINE_GLYPH_USAGE 1 /* Old code = 0, new code = 1 */
33
/* ---------------- Acrobat limitations ---------------- */
36
* The PDF reference manual, 2nd ed., claims that the limit for coordinates
37
* is +/- 32767. However, testing indicates that Acrobat Reader 4 for
38
* Windows and Linux fail with coordinates outside +/- 16383. Hence, we
39
* limit coordinates to 16k, with a little slop.
41
#define MAX_USER_COORD 16300
43
/* ---------------- Statically allocated sizes ---------------- */
44
/* These should really be dynamic.... */
46
/* Define the maximum depth of an outline tree. */
47
/* Note that there is no limit on the breadth of the tree. */
48
#define MAX_OUTLINE_DEPTH 32
50
/* Define the maximum size of a destination array string. */
51
#define MAX_DEST_STRING 80
53
/* ================ Types and structures ================ */
55
/* Define the possible contexts for the output stream. */
63
/* ---------------- Cos objects ---------------- */
66
* These are abstract types for cos objects. The concrete types are in
69
typedef struct cos_object_s cos_object_t;
70
typedef struct cos_stream_s cos_stream_t;
71
typedef struct cos_dict_s cos_dict_t;
72
typedef struct cos_array_s cos_array_t;
73
typedef struct cos_value_s cos_value_t;
74
typedef struct cos_object_procs_s cos_object_procs_t;
75
typedef const cos_object_procs_t *cos_type_t;
76
#define cos_types_DEFINED
78
#ifndef pdf_text_state_DEFINED
79
# define pdf_text_state_DEFINED
80
typedef struct pdf_text_state_s pdf_text_state_t;
83
#ifndef pdf_char_glyph_pairs_DEFINED
84
# define pdf_char_glyph_pairs_DEFINED
85
typedef struct pdf_char_glyph_pairs_s pdf_char_glyph_pairs_t;
88
/* ---------------- Resources ---------------- */
92
* Standard PDF resources. Font must be last, because resources
93
* up to but not including Font are written page-by-page.
100
resourceOther, /* Anything else that needs to be stored for a time.
101
* Can be any of the types defined below NUM_RESOURCE_TYPES
102
* but this is the type used to identify the object.
106
* Internally used (pseudo-)resources.
111
resourceFontDescriptor,
113
resourceSoftMaskDict,
117
/* These resource types were 'resourceOther', but we want to track them
118
* for ps2write. They are not stored in the pdf device structure, unlike
119
* the reource types above.
122
resourceCIDSystemInfo,
137
resourceNone /* Special, used when this isn't a resource at all
138
* eg when we execute a resource we've just written, such as
141
} pdf_resource_type_t;
143
#define PDF_RESOURCE_TYPE_NAMES\
144
"/ColorSpace", "/ExtGState", "/Pattern", "/Shading", "/XObject", 0, "/Font",\
145
0, "/Font", "/CMap", "/FontDescriptor", "/Group", "/Mask", 0, 0, 0, 0, 0,\
146
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
147
#define PDF_RESOURCE_TYPE_STRUCTS\
148
&st_pdf_color_space, /* gdevpdfg.h / gdevpdfc.c */\
149
&st_pdf_resource, /* see below */\
152
&st_pdf_x_object, /* see below */\
154
&st_pdf_font_resource, /* gdevpdff.h / gdevpdff.c */\
155
&st_pdf_char_proc, /* gdevpdff.h / gdevpdff.c */\
156
&st_pdf_font_resource, /* gdevpdff.h / gdevpdff.c */\
158
&st_pdf_font_descriptor, /* gdevpdff.h / gdevpdff.c */\
165
* rname is currently R<id> for all resources other than synthesized fonts;
166
* for synthesized fonts, rname is A, B, .... The string is null-terminated.
169
#define pdf_resource_common(typ)\
170
typ *next; /* next resource of this type */\
171
pdf_resource_t *prev; /* previously allocated resource */\
172
gs_id rid; /* optional ID key */\
174
bool global; /* ps2write only */\
175
char rname[1/*R*/ + (sizeof(long) * 8 / 3 + 1) + 1/*\0*/];\
176
ulong where_used; /* 1 bit per level of content stream */\
178
typedef struct pdf_resource_s pdf_resource_t;
179
struct pdf_resource_s {
180
pdf_resource_common(pdf_resource_t);
183
/* The descriptor is public for subclassing. */
184
extern_st(st_pdf_resource);
185
#define public_st_pdf_resource() /* in gdevpdfu.c */\
186
gs_public_st_ptrs3(st_pdf_resource, pdf_resource_t, "pdf_resource_t",\
187
pdf_resource_enum_ptrs, pdf_resource_reloc_ptrs, next, prev, object)
190
* We define XObject resources here because they are used for Image,
191
* Form, and PS XObjects, which are implemented in different files.
193
typedef struct pdf_x_object_s pdf_x_object_t;
194
struct pdf_x_object_s {
195
pdf_resource_common(pdf_x_object_t);
196
int width, height; /* specified width and height for images */
197
int data_height; /* actual data height for images */
199
#define private_st_pdf_x_object() /* in gdevpdfu.c */\
200
gs_private_st_suffix_add0(st_pdf_x_object, pdf_x_object_t,\
201
"pdf_x_object_t", pdf_x_object_enum_ptrs, pdf_x_object_reloc_ptrs,\
204
/* Define the mask for which procsets have been used on a page. */
213
/* ------ Fonts ------ */
215
/* Define abstract types. */
216
typedef struct pdf_char_proc_s pdf_char_proc_t; /* gdevpdff.h */
217
typedef struct pdf_char_proc_ownership_s pdf_char_proc_ownership_t; /* gdevpdff.h */
218
typedef struct pdf_font_s pdf_font_t; /* gdevpdff.h */
219
typedef struct pdf_text_data_s pdf_text_data_t; /* gdevpdft.h */
221
/* ---------------- Other auxiliary structures ---------------- */
223
/* Outline nodes and levels */
224
typedef struct pdf_outline_node_s {
225
long id, parent_id, prev_id, first_id, last_id;
228
} pdf_outline_node_t;
229
typedef struct pdf_outline_level_s {
230
pdf_outline_node_t first;
231
pdf_outline_node_t last;
233
} pdf_outline_level_t;
235
* The GC descriptor is implicit, since outline levels occur only in an
236
* embedded array in the gx_device_pdf structure.
240
typedef struct pdf_bead_s {
241
long id, article_id, prev_id, next_id, page_id;
244
typedef struct pdf_article_s pdf_article_t;
245
struct pdf_article_s {
247
cos_dict_t *contents;
252
#define private_st_pdf_article()\
253
gs_private_st_ptrs2(st_pdf_article, pdf_article_t,\
254
"pdf_article_t", pdf_article_enum_ptrs, pdf_article_reloc_ptrs,\
257
/* ---------------- The device structure ---------------- */
260
#define NUM_RESOURCE_CHAINS 16
261
typedef struct pdf_resource_list_s {
262
pdf_resource_t *chains[NUM_RESOURCE_CHAINS];
263
} pdf_resource_list_t;
265
/* Define the hash function for gs_ids. */
266
#define gs_id_hash(rid) ((rid) + ((rid) / NUM_RESOURCE_CHAINS))
267
/* Define the accessor for the proper hash chain. */
268
#define PDF_RESOURCE_CHAIN(pdev, type, rid)\
269
(&(pdev)->resources[type].chains[gs_id_hash(rid) % NUM_RESOURCE_CHAINS])
271
/* Define the bookkeeping for an open stream. */
272
typedef struct pdf_stream_position_s {
275
} pdf_stream_position_t;
278
* Define the structure for keeping track of text rotation.
279
* There is one for the current page (for AutoRotate /PageByPage)
280
* and one for the whole document (for AutoRotate /All).
282
typedef struct pdf_text_rotation_s {
283
long counts[5]; /* 0, 90, 180, 270, other */
284
int Rotate; /* computed rotation, -1 means none */
285
} pdf_text_rotation_t;
286
#define pdf_text_rotation_angle_values 0, 90, 180, 270, -1
289
* Define document and page information derived from DSC comments.
291
typedef struct pdf_page_dsc_info_s {
292
int orientation; /* -1 .. 3 */
293
int viewing_orientation; /* -1 .. 3 */
294
gs_rect bounding_box;
295
} pdf_page_dsc_info_t;
298
* Define the stored information for a page. Because pdfmarks may add
299
* information to any page anywhere in the document, we have to wait
300
* until the end to write the page dictionaries.
302
typedef struct pdf_page_s {
305
pdf_procset_t procsets;
307
long resource_ids[resourceFont + 1]; /* resources thru Font, see above */
310
pdf_text_rotation_t text_rotation;
311
pdf_page_dsc_info_t dsc_info;
312
bool NumCopies_set; /* ps2write only. */
313
int NumCopies; /* ps2write only. */
315
#define private_st_pdf_page() /* in gdevpdf.c */\
316
gs_private_st_ptrs2(st_pdf_page, pdf_page_t, "pdf_page_t",\
317
pdf_page_enum_ptrs, pdf_page_reloc_ptrs, Page, Annots)
320
* Define the structure for the temporary files used while writing.
321
* There are 4 of these, described below.
323
typedef struct pdf_temp_file_s {
324
char file_name[gp_file_name_sizeof];
328
stream *save_strm; /* save pdev->strm while writing here */
331
#ifndef gx_device_pdf_DEFINED
332
# define gx_device_pdf_DEFINED
333
typedef struct gx_device_pdf_s gx_device_pdf;
337
* Define the structure for PDF font cache element.
339
typedef struct pdf_font_cache_elem_s pdf_font_cache_elem_t;
340
struct pdf_font_cache_elem_s {
341
pdf_font_cache_elem_t *next;
343
int num_chars; /* safety purpose only */
344
int num_widths; /* safety purpose only */
345
struct pdf_font_resource_s *pdfont;
347
double *real_widths; /* [count] (not used for Type 0) */
348
gx_device_pdf *pdev; /* For pdf_remove_font_cache_elem */
351
#define private_st_pdf_font_cache_elem()\
352
gs_private_st_ptrs5(st_pdf_font_cache_elem, pdf_font_cache_elem_t,\
353
"pdf_font_cache_elem_t", pdf_font_cache_elem_enum,\
354
pdf_font_cache_elem_reloc, next, pdfont,\
355
glyph_usage, real_widths, pdev)
358
* pdf_viewer_state tracks the graphic state of a viewer,
359
* which would interpret the generated PDF file
360
* immediately when it is generated.
362
typedef struct pdf_viewer_state_s {
363
int transfer_not_identity; /* bitmask */
364
gs_id transfer_ids[4];
365
float opacity_alpha; /* state.opacity.alpha */
366
float shape_alpha; /* state.shape.alpha */
367
gs_blend_mode_t blend_mode; /* state.blend_mode */
369
gs_id black_generation_id;
370
gs_id undercolor_removal_id;
372
float smoothness; /* state.smoothness */
374
bool text_knockout; /* state.text_knockout */
376
bool stroke_overprint;
377
bool stroke_adjust; /* state.stroke_adjust */
378
bool fill_used_process_color;
379
bool stroke_used_process_color;
380
gx_hl_saved_color saved_fill_color;
381
gx_hl_saved_color saved_stroke_color;
382
gx_line_params line_params;
383
float dash_pattern[max_dash];
388
* Define a structure for saving context when entering
389
* a contents stream accumulation mode (charproc, Type 1 pattern).
391
typedef struct pdf_substream_save_s {
392
pdf_context_t context;
393
pdf_text_state_t *text_state;
398
cos_dict_t *substream_Resources;
399
pdf_procset_t procsets;
401
pdf_resource_t *font3;
402
pdf_resource_t *accumulating_substream_resource;
403
bool charproc_just_accumulated;
404
bool accumulating_a_global_object;
405
pdf_resource_t *pres_soft_mask_dict;
406
gs_const_string objname;
407
int last_charpath_op;
408
} pdf_substream_save;
410
#define private_st_pdf_substream_save()\
411
gs_private_st_strings1_ptrs7(st_pdf_substream_save, pdf_substream_save,\
412
"pdf_substream_save", pdf_substream_save_enum,\
413
pdf_substream_save_reloc, objname, text_state, clip_path, strm, \
414
substream_Resources, font3, accumulating_substream_resource, pres_soft_mask_dict)
415
#define private_st_pdf_substream_save_element()\
416
gs_private_st_element(st_pdf_substream_save_element, pdf_substream_save,\
417
"pdf_substream_save[]", pdf_substream_save_elt_enum_ptrs,\
418
pdf_substream_save_elt_reloc_ptrs, st_pdf_substream_save)
422
pdf_compress_LZW, /* not currently used, thanks to Unisys */
424
} pdf_compression_type;
426
/* Define the device structure. */
427
struct gx_device_pdf_s {
428
gx_device_psdf_common;
429
bool is_ps2write; /* ps2write (true) versus pdfwrite (false); never changed */
430
/* PDF-specific distiller parameters */
431
double CompatibilityLevel;
435
bool ParseDSCCommentsForDocInfo;
436
bool ParseDSCComments;
437
bool EmitDSCWarnings;
438
bool CreateJobTicket;
439
bool PreserveEPSInfo;
440
bool AutoPositionEPSFiles;
441
bool PreserveCopyPage;
443
int OffOptimizations;
444
/* End of distiller parameters */
445
/* PDF/X parameters */
446
gs_param_float_array PDFXTrimBoxToMediaBoxOffset;
447
gs_param_float_array PDFXBleedBoxToTrimBoxOffset;
448
bool PDFXSetBleedBoxToMediaBox;
449
/* Other parameters */
450
bool ReAssignCharacters;
451
bool ReEncodeCharacters;
452
long FirstObjectNumber;
454
bool PrintStatistics;
455
gs_param_string DocumentUUID;
456
gs_param_string InstanceUUID;
458
bool ForOPDFRead; /* PS2WRITE only. */
459
bool CompressEntireFile; /* PS2WRITE only. */
460
bool ResourcesBeforeUsage; /* PS2WRITE only. */
461
bool HavePDFWidths; /* PS2WRITE only. */
462
bool HaveStrokeColor; /* PS2WRITE only. */
463
bool ProduceDSC; /* PS2WRITE only. */
464
bool HaveTransparency;
465
bool PatternImagemask; /* The target viewer|printer handles imagemask
466
with pattern color. */
467
bool PDFX; /* Generate PDF/X */
468
bool PDFA; /* Generate PDF/A */
469
bool AbortPDFAX; /* Abort generation of PDFA or X, produce regular PDF */
470
long MaxClipPathSize; /* The maximal number of elements of a clipping path
471
that the target viewer|printer can handle. */
472
long MaxViewerMemorySize;
473
long MaxShadingBitmapSize; /* The maximal number of bytes in
474
a bitmap representation of a shading.
475
(Bigger shadings to be downsampled). */
476
long MaxInlineImageSize;
477
gs_param_int_array DSCEncodingToUnicode;
478
/* Encryption parameters */
479
gs_param_string OwnerPassword;
480
gs_param_string UserPassword;
484
gs_param_string NoEncrypt;
485
bool EncryptMetadata;
486
/* End of parameters */
487
bool ComputeDocumentDigest; /* Developer needs only; Always true in production. */
488
/* Encryption data */
489
byte EncryptionO[32];
490
byte EncryptionU[32];
491
byte EncryptionKey[16];
493
/* Values derived from DSC comments */
495
pdf_page_dsc_info_t doc_dsc_info; /* document default */
496
pdf_page_dsc_info_t page_dsc_info; /* current page */
497
/* Additional graphics state */
498
bool fill_overprint, stroke_overprint;
499
bool remap_fill_color, remap_stroke_color;
502
gs_id transfer_ids[4];
503
int transfer_not_identity; /* bitmask */
504
gs_id black_generation_id, undercolor_removal_id;
505
/* Following are set when device is opened. */
506
pdf_compression_type compression;
507
pdf_compression_type compression_at_page_start;
508
#define pdf_memory v_memory
510
* The xref temporary file is logically an array of longs.
511
* xref[id - FirstObjectNumber] is the position in the output file
512
* of the object with the given id.
514
* Note that xref, unlike the other temporary files, does not have
515
* an associated stream or stream buffer.
517
pdf_temp_file_t xref;
519
* asides holds resources and other "aside" objects. It is
520
* copied verbatim to the output file at the end of the document.
522
pdf_temp_file_t asides;
524
* streams holds data for stream-type Cos objects. The data is
525
* copied to the output file at the end of the document.
527
* Note that streams.save_strm is not used, since we don't interrupt
528
* normal output when saving stream data.
530
pdf_temp_file_t streams;
532
* pictures holds graphic objects being accumulated between BP and EP.
533
* The object is moved to streams when the EP is reached: since BP and
534
* EP nest, we delete the object from the pictures file at that time.
536
pdf_temp_file_t pictures;
537
/* ................ */
539
/* The following 3 objects, and only these, are allocated */
540
/* when the file is opened. */
544
#define pdf_num_initial_ids 3
547
int max_referred_page;
549
pdf_context_t context;
550
long contents_length_id;
552
pdf_procset_t procsets; /* used on this page */
553
pdf_text_data_t *text;
554
pdf_text_rotation_t text_rotation;
555
#define initial_num_pages 50
558
ulong used_mask; /* for where_used: page level = 1 */
559
pdf_resource_list_t resources[NUM_RESOURCE_TYPES];
560
/* cs_Patterns[0] is colored; 1,3,4 are uncolored + Gray,RGB,CMYK */
561
pdf_resource_t *cs_Patterns[5];
562
pdf_resource_t *Identity_ToUnicode_CMaps[2]; /* WMode = 0,1 */
563
pdf_resource_t *last_resource;
564
pdf_resource_t *OneByteIdentityH;
565
gs_id IdentityCIDSystemInfo_id;
566
pdf_outline_level_t outline_levels[MAX_OUTLINE_DEPTH];
568
int closed_outline_depth;
570
pdf_article_t *articles;
573
/* Use a single time moment for all UUIDs to minimize an indeterminizm. */
576
* global_named_objects holds named objects that are independent of
577
* the current namespace: {Catalog}, {DocInfo}, {Page#}, {ThisPage},
578
* {PrevPage}, {NextPage}.
580
cos_dict_t *global_named_objects;
582
* local_named_objects holds named objects in the current namespace.
584
cos_dict_t *local_named_objects;
586
* NI_stack is a last-in, first-out stack in which each element is a
587
* (named) cos_stream_t object that eventually becomes the object of an
588
* image XObject resource.
590
cos_array_t *NI_stack;
592
* Namespace_stack is a last-in, first-out stack in which each pair of
593
* elements is, respectively, a saved value of local_named_objects and
594
* a saved value of NI_stack. (The latter is not documented by Adobe,
595
* but it was confirmed by them.)
597
cos_array_t *Namespace_stack;
598
pdf_font_cache_elem_t *font_cache;
600
* char_width is used by pdf_text_set_cache to communicate
601
* with assign_char_code around gdev_pdf_fill_mask.
605
* We need a stable copy of clipping path to prevent writing
606
* redundant clipping paths when PS document generates such ones.
612
cos_array_t *PageLabels;
613
int PageLabels_current_page;
614
cos_dict_t *PageLabels_current_label;
616
* The following is a dangerous pointer, which pdf_text_process
617
* uses to communicate with assign_char_code.
618
* It is a pointer from global memory to local memory.
619
* The garbager must not proceess this pointer, and it must
620
* not be listed in st_device_pdfwrite.
621
* It's life time terminates on garbager invocation.
625
* The viewer's graphic state stack.
626
* We restrict its length with the strongest PDF spec limitation.
627
* Usually 5 levels is enough, but patterns and charprocs may be nested recursively.
629
pdf_viewer_state vgstack[11];
631
int vgstack_bottom; /* Stack bottom for the current substream. */
632
pdf_viewer_state vg_initial; /* Initial values for viewer's graphic state */
635
/* The substream context stack. */
638
pdf_substream_save *sbstack;
640
/* Temporary workaround. The only way to get forms out of pdfwrite at present
641
* is via a transparency group or mask operation. Ordinarily we don't care
642
* much about forms, but Patterns within forms need to be scaled to the
643
* CTM of the Pattern, not the default page co-ordinate system. We use
644
* this value to know if we are nested inside a form or not. If we are
645
* we don't undo the resolution co-ordinate transform.
650
cos_dict_t *substream_Resources; /* Substream resources */
651
gs_color_space_index pcm_color_info_index; /* Index of the ProcessColorModel space. */
652
bool skip_colors; /* Skip colors while a pattern/charproc accumulation. */
653
bool AR4_save_bug; /* See pdf_put_uncolored_pattern */
654
pdf_resource_t *font3; /* The owner of the accumulated charstring. */
655
pdf_resource_t *accumulating_substream_resource;
656
gs_matrix_fixed charproc_ctm;
657
bool charproc_just_accumulated; /* A flag for controlling
658
the glyph variation recognition.
659
Used only with uncached charprocs. */
660
bool PS_accumulator; /* A flag to determine whether a given
661
accumulator is for a PostScript type 3 font or not. */
662
bool accumulating_a_global_object; /* ps2write only.
663
Accumulating a global object (such as a named Form,
664
so that resources used in it must also be global.
665
Important for viewers with small memory,
666
which drops resources per page. */
667
const pdf_char_glyph_pairs_t *cgp; /* A temporary pointer
668
for pdf_is_same_charproc1.
669
Must be NULL when the garbager is invoked,
670
because it points from global to local memory. */
671
int substituted_pattern_count;
672
int substituted_pattern_drop_page;
673
/* Temporary data for use_image_as_pattern,
674
They pass an information about a mask of a masked image,
675
(which is being converted into a pattern)
676
between 2 consecutive calls to pdf_image_end_image_data. */
678
bool image_mask_is_SMask;
679
bool image_mask_skip; /* A flag for pdf_begin_transparency_mask */
680
bool image_with_SMask; /* A flag for pdf_begin_transparency_group. */
681
gs_matrix converting_image_matrix;
682
double image_mask_scale;
683
/* Temporary data for soft mask form. */
684
pdf_resource_t *pres_soft_mask_dict;
685
/* Temporary data for pdfmark_BP. */
686
gs_const_string objname;
687
int OPDFRead_procset_length; /* PS2WRITE only. */
688
void *find_resource_param; /* WARNING : not visible for garbager. */
689
int last_charpath_op; /* true or false state of last charpath */
696
bool PreserveSeparation;
697
bool PreserveDeviceN;
698
int PDFACompatibilityPolicy;
699
bool DetectDuplicateImages;
700
bool AllowIncrementalCFF;
701
bool HighLevelDevice;
703
bool AllowPSRepeatFunctions;
709
#define is_in_page(pdev)\
710
((pdev)->contents_id != 0)
711
#define is_in_document(pdev)\
712
(is_in_page(pdev) || (pdev)->last_resource != 0)
714
/* Enumerate the individual pointers in a gx_device_pdf. */
715
#define gx_device_pdf_do_ptrs(m)\
716
m(0,asides.strm) m(1,asides.strm_buf) m(2,asides.save_strm)\
717
m(3,streams.strm) m(4,streams.strm_buf)\
718
m(5,pictures.strm) m(6,pictures.strm_buf) m(7,pictures.save_strm)\
719
m(8,Catalog) m(9,Info) m(10,Pages)\
720
m(11,text) m(12,pages)\
721
m(13,cs_Patterns[0])\
722
m(14,cs_Patterns[1]) m(15,cs_Patterns[3]) m(16,cs_Patterns[4])\
724
m(18,articles) m(19,Dests) m(20,global_named_objects)\
725
m(21, local_named_objects) m(22,NI_stack) m(23,Namespace_stack)\
726
m(24,font_cache) m(25,clip_path)\
727
m(26,PageLabels) m(27,PageLabels_current_label)\
728
m(28,sbstack) m(29,substream_Resources) m(30,font3)\
729
m(31,accumulating_substream_resource) \
730
m(32,pres_soft_mask_dict) m(33,PDFXTrimBoxToMediaBoxOffset.data)\
731
m(34,PDFXBleedBoxToTrimBoxOffset.data) m(35, DSCEncodingToUnicode.data)\
732
m(36,Identity_ToUnicode_CMaps[0]) m(37,Identity_ToUnicode_CMaps[1])
733
#define gx_device_pdf_num_ptrs 38
734
#define gx_device_pdf_do_param_strings(m)\
735
m(0, OwnerPassword) m(1, UserPassword) m(2, NoEncrypt)\
736
m(3, DocumentUUID) m(4, InstanceUUID)
737
#define gx_device_pdf_num_param_strings 5
738
#define gx_device_pdf_do_const_strings(m)\
740
#define gx_device_pdf_num_const_strings 1
741
#define st_device_pdf_max_ptrs\
742
(st_device_psdf_max_ptrs + gx_device_pdf_num_ptrs +\
743
gx_device_pdf_num_param_strings + gx_device_pdf_num_const_strings +\
744
NUM_RESOURCE_TYPES * NUM_RESOURCE_CHAINS /* resources[].chains[] */ +\
745
MAX_OUTLINE_DEPTH * 2 /* outline_levels[].{first,last}.action */
747
#define private_st_device_pdfwrite() /* in gdevpdf.c */\
748
gs_private_st_composite_final(st_device_pdfwrite, gx_device_pdf,\
749
"gx_device_pdf", device_pdfwrite_enum_ptrs, device_pdfwrite_reloc_ptrs,\
750
device_pdfwrite_finalize)
752
/* ================ Driver procedures ================ */
755
dev_proc_copy_mono(gdev_pdf_copy_mono);
756
dev_proc_copy_color(gdev_pdf_copy_color);
757
dev_proc_fill_mask(gdev_pdf_fill_mask);
758
dev_proc_strip_tile_rectangle(gdev_pdf_strip_tile_rectangle);
760
extern const gx_device_vector_procs pdf_vector_procs;
761
dev_proc_fill_rectangle(gdev_pdf_fill_rectangle);
762
dev_proc_fill_path(gdev_pdf_fill_path);
763
dev_proc_stroke_path(gdev_pdf_stroke_path);
764
dev_proc_fillpage(gdev_pdf_fillpage);
766
dev_proc_begin_typed_image(gdev_pdf_begin_typed_image);
768
dev_proc_get_params(gdev_pdf_get_params);
769
dev_proc_put_params(gdev_pdf_put_params);
771
dev_proc_text_begin(gdev_pdf_text_begin);
772
dev_proc_fill_rectangle_hl_color(gdev_pdf_fill_rectangle_hl_color);
774
dev_proc_include_color_space(gdev_pdf_include_color_space);
776
dev_proc_create_compositor(gdev_pdf_create_compositor);
777
dev_proc_begin_transparency_group(gdev_pdf_begin_transparency_group);
778
dev_proc_end_transparency_group(gdev_pdf_end_transparency_group);
779
dev_proc_begin_transparency_mask(gdev_pdf_begin_transparency_mask);
780
dev_proc_end_transparency_mask(gdev_pdf_end_transparency_mask);
781
dev_proc_discard_transparency_layer(gdev_pdf_discard_transparency_layer);
782
dev_proc_dev_spec_op(gdev_pdf_dev_spec_op);
784
/* ================ Utility procedures ================ */
786
/* ---------------- Exported by gdevpdf.c ---------------- */
788
/* Initialize the IDs allocated at startup. */
789
void pdf_initialize_ids(gx_device_pdf * pdev);
791
/* Update the color mapping procedures after setting ProcessColorModel. */
792
void pdf_set_process_color_model(gx_device_pdf * pdev, int index);
794
/* Reset the text state parameters to initial values. */
795
void pdf_reset_text(gx_device_pdf *pdev);
797
/* ---------------- Exported by gdevpdfu.c ---------------- */
799
/* ------ Document ------ */
801
/* Write a DSC compliant header to the file */
802
int ps2write_dsc_header(gx_device_pdf * pdev, int pages);
804
/* Open the document if necessary. */
805
int pdf_open_document(gx_device_pdf * pdev);
807
/* ------ Objects ------ */
809
/* Allocate an ID for a future object, set its pos=0 so we can tell if it is used */
810
long pdf_obj_forward_ref(gx_device_pdf * pdev);
812
/* Allocate an ID for a future object. */
813
long pdf_obj_ref(gx_device_pdf * pdev);
815
/* Read the current position in the output stream. */
816
long pdf_stell(gx_device_pdf * pdev);
818
/* Begin an object, optionally allocating an ID. */
819
long pdf_open_obj(gx_device_pdf * pdev, long id, pdf_resource_type_t type);
820
long pdf_begin_obj(gx_device_pdf * pdev, pdf_resource_type_t type);
823
int pdf_end_obj(gx_device_pdf * pdev, pdf_resource_type_t type);
825
/* ------ Page contents ------ */
827
/* Open a page contents part. */
828
/* Return an error if the page has too many contents parts. */
829
int pdf_open_contents(gx_device_pdf * pdev, pdf_context_t context);
831
/* Close the current contents part if we are in one. */
832
int pdf_close_contents(gx_device_pdf * pdev, bool last);
834
/* ------ Resources et al ------ */
836
extern const char *const pdf_resource_type_names[];
837
extern const gs_memory_struct_type_t *const pdf_resource_type_structs[];
840
* Define the offset that indicates that a file position is in the
841
* asides file rather than the main (contents) file.
842
* Must be a power of 2, and larger than the largest possible output file.
844
#define ASIDES_BASE_POSITION min_long
846
/* Begin an object logically separate from the contents. */
847
/* (I.e., an object in the resource file.) */
848
long pdf_open_separate(gx_device_pdf * pdev, long id, pdf_resource_type_t type);
849
long pdf_begin_separate(gx_device_pdf * pdev, pdf_resource_type_t type);
851
/* Reserve object id. */
852
void pdf_reserve_object_id(gx_device_pdf * pdev, pdf_resource_t *ppres, long id);
854
/* Begin an aside (resource, annotation, ...). */
855
int pdf_alloc_aside(gx_device_pdf * pdev, pdf_resource_t ** plist,
856
const gs_memory_struct_type_t * pst, pdf_resource_t **ppres,
858
/* Begin an aside (resource, annotation, ...). */
859
int pdf_begin_aside(gx_device_pdf * pdev, pdf_resource_t **plist,
860
const gs_memory_struct_type_t * pst,
861
pdf_resource_t **ppres, pdf_resource_type_t type);
863
/* Begin a resource of a given type. */
864
int pdf_begin_resource(gx_device_pdf * pdev, pdf_resource_type_t rtype,
865
gs_id rid, pdf_resource_t **ppres);
867
/* Begin a resource body of a given type. */
868
int pdf_begin_resource_body(gx_device_pdf * pdev, pdf_resource_type_t rtype,
869
gs_id rid, pdf_resource_t **ppres);
871
/* Allocate a resource, but don't open the stream. */
872
int pdf_alloc_resource(gx_device_pdf * pdev, pdf_resource_type_t rtype,
873
gs_id rid, pdf_resource_t **ppres, long id);
875
/* Find same resource. */
876
int pdf_find_same_resource(gx_device_pdf * pdev,
877
pdf_resource_type_t rtype, pdf_resource_t **ppres,
878
int (*eq)(gx_device_pdf * pdev, pdf_resource_t *pres0, pdf_resource_t *pres1));
880
/* Find resource by resource id. */
881
pdf_resource_t *pdf_find_resource_by_resource_id(gx_device_pdf * pdev,
882
pdf_resource_type_t rtype, gs_id id);
884
/* Find a resource of a given type by gs_id. */
885
pdf_resource_t *pdf_find_resource_by_gs_id(gx_device_pdf * pdev,
886
pdf_resource_type_t rtype,
889
void pdf_drop_resources(gx_device_pdf * pdev, pdf_resource_type_t rtype,
890
int (*cond)(gx_device_pdf * pdev, pdf_resource_t *pres));
892
/* Print resource statistics. */
893
void pdf_print_resource_statistics(gx_device_pdf * pdev);
895
/* Cancel a resource (do not write it into PDF). */
896
int pdf_cancel_resource(gx_device_pdf * pdev, pdf_resource_t *pres,
897
pdf_resource_type_t rtype);
899
/* Remove a resource. */
900
void pdf_forget_resource(gx_device_pdf * pdev, pdf_resource_t *pres1,
901
pdf_resource_type_t rtype);
903
/* Substitute a resource with a same one. */
904
int pdf_substitute_resource(gx_device_pdf *pdev, pdf_resource_t **ppres,
905
pdf_resource_type_t rtype,
906
int (*eq)(gx_device_pdf *pdev, pdf_resource_t *pres0, pdf_resource_t *pres1),
909
/* Get the object id of a resource. */
910
long pdf_resource_id(const pdf_resource_t *pres);
912
/* End a separate object. */
913
int pdf_end_separate(gx_device_pdf * pdev, pdf_resource_type_t type);
916
int pdf_end_aside(gx_device_pdf * pdev, pdf_resource_type_t type);
918
/* End a resource. */
919
int pdf_end_resource(gx_device_pdf * pdev, pdf_resource_type_t type);
922
* Write the Cos objects for resources local to a content stream.
924
int pdf_write_resource_objects(gx_device_pdf *pdev, pdf_resource_type_t rtype);
927
* Reverse resource chains.
928
* ps2write uses it with page resources.
929
* Assuming only the 0th chain contauns something.
931
void pdf_reverse_resource_chain(gx_device_pdf *pdev, pdf_resource_type_t rtype);
934
* Free unnamed Cos objects for resources local to a content stream.
936
int pdf_free_resource_objects(gx_device_pdf *pdev, pdf_resource_type_t rtype);
938
/* Write and free all resource objects. */
940
int pdf_write_and_free_all_resource_objects(gx_device_pdf *pdev);
943
* Store the resource sets for a content stream (page or XObject).
944
* Sets page->{procsets, resource_ids[], fonts_id}.
946
int pdf_store_page_resources(gx_device_pdf *pdev, pdf_page_t *page, bool clear_usage);
948
/* Copy data from a temporary file to a stream. */
949
void pdf_copy_data(stream *s, FILE *file, long count, stream_arcfour_state *ss);
950
void pdf_copy_data_safe(stream *s, FILE *file, int64_t position, long count);
952
/* Add the encryption filter. */
953
int pdf_begin_encrypt(gx_device_pdf * pdev, stream **s, gs_id object_id);
954
/* Remove the encryption filter. */
955
void pdf_end_encrypt(gx_device_pdf * pdev);
956
/* Initialize encryption. */
957
int pdf_encrypt_init(const gx_device_pdf * pdev, gs_id object_id, stream_arcfour_state *psarc4);
959
/* ------ Pages ------ */
961
/* Get or assign the ID for a page. */
962
/* Returns 0 if the page number is out of range. */
963
long pdf_page_id(gx_device_pdf * pdev, int page_num);
965
/* Get the page structure for the current page. */
966
pdf_page_t *pdf_current_page(gx_device_pdf *pdev);
968
/* Get the dictionary object for the current page. */
969
cos_dict_t *pdf_current_page_dict(gx_device_pdf *pdev);
971
/* Open a page for writing. */
972
int pdf_open_page(gx_device_pdf * pdev, pdf_context_t context);
974
/* Go to the unclipped stream context. */
975
int pdf_unclip(gx_device_pdf * pdev);
977
/* Write saved page- or document-level information. */
978
int pdf_write_saved_string(gx_device_pdf * pdev, gs_string * pstr);
980
/* ------ Path drawing ------ */
982
/* Store a copy of clipping path. */
983
int pdf_remember_clip_path(gx_device_pdf * pdev, const gx_clip_path * pcpath);
985
/* Test whether the clip path needs updating. */
986
bool pdf_must_put_clip_path(gx_device_pdf * pdev, const gx_clip_path * pcpath);
988
/* Write and update the clip path. */
989
int pdf_put_clip_path(gx_device_pdf * pdev, const gx_clip_path * pcpath);
991
/* ------ Masked image convertion ------ */
993
typedef struct pdf_lcvd_s {
994
gx_device_memory mdev;
995
gx_device_memory *mask;
997
dev_t_proc_copy_color((*std_copy_color), gx_device);
998
dev_t_proc_fill_rectangle((*std_fill_rectangle), gx_device);
999
dev_t_proc_close_device((*std_close_device), gx_device);
1000
dev_t_proc_get_clipping_box((*std_get_clipping_box), gx_device);
1005
bool has_background;
1007
gs_point path_offset;
1010
#define public_st_pdf_lcvd_t()\
1011
gs_public_st_suffix_add2(st_pdf_lcvd_t, pdf_lcvd_t,\
1012
"pdf_lcvd_t", pdf_lcvd_t_enum_ptrs,\
1013
pdf_lcvd_t_reloc_ptrs, st_device_memory, mask, pdev)
1014
#define pdf_lcvd_t_max_ptrs (gx_device_memory_max_ptrs + 2)
1016
int pdf_setup_masked_image_converter(gx_device_pdf *pdev, gs_memory_t *mem, const gs_matrix *m, pdf_lcvd_t **pcvd,
1017
bool need_mask, int x, int y, int w, int h, bool write_on_close);
1018
int pdf_dump_converted_image(gx_device_pdf *pdev, pdf_lcvd_t *cvd);
1019
void pdf_remove_masked_image_converter(gx_device_pdf *pdev, pdf_lcvd_t *cvd, bool need_mask);
1021
/* ------ Miscellaneous output ------ */
1023
#define PDF_MAX_PRODUCER 200 /* adhoc */
1024
/* Generate the default Producer string. */
1025
void pdf_store_default_Producer(char buf[PDF_MAX_PRODUCER]);
1027
/* Define the strings for filter names and parameters. */
1028
typedef struct pdf_filter_names_s {
1029
const char *ASCII85Decode;
1030
const char *ASCIIHexDecode;
1031
const char *CCITTFaxDecode;
1032
const char *DCTDecode;
1033
const char *DecodeParms;
1035
const char *FlateDecode;
1036
const char *LZWDecode;
1037
const char *RunLengthDecode;
1038
const char *JBIG2Decode;
1039
const char *JPXDecode;
1040
} pdf_filter_names_t;
1041
#define PDF_FILTER_NAMES\
1042
"/ASCII85Decode", "/ASCIIHexDecode", "/CCITTFaxDecode",\
1043
"/DCTDecode", "/DecodeParms", "/Filter", "/FlateDecode",\
1044
"/LZWDecode", "/RunLengthDecode", "/JBIG2Decode", "/JPXDecode"
1045
#define PDF_FILTER_NAMES_SHORT\
1046
"/A85", "/AHx", "/CCF", "/DCT", "/DP", "/F", "/Fl", "/LZW", "/RL", "/???", "/???"
1048
/* Write matrix values. */
1049
void pdf_put_matrix(gx_device_pdf *pdev, const char *before,
1050
const gs_matrix *pmat, const char *after);
1052
/* Write a name, with escapes for unusual characters. */
1053
typedef int (*pdf_put_name_chars_proc_t)(stream *, const byte *, uint);
1054
pdf_put_name_chars_proc_t
1055
pdf_put_name_chars_proc(const gx_device_pdf *pdev);
1056
int pdf_put_name_chars(const gx_device_pdf *pdev, const byte *nstr,
1058
int pdf_put_name(const gx_device_pdf *pdev, const byte *nstr, uint size);
1060
/* Write a string in its shortest form ( () or <> ). */
1061
int pdf_put_string(const gx_device_pdf *pdev, const byte *str, uint size);
1063
/* Write a value, treating names specially. */
1064
int pdf_write_value(const gx_device_pdf *pdev, const byte *vstr, uint size, gs_id object_id);
1066
/* Store filters for a stream. */
1067
int pdf_put_filters(cos_dict_t *pcd, gx_device_pdf *pdev, stream *s,
1068
const pdf_filter_names_t *pfn);
1070
/* Define a possibly encoded and compressed data stream. */
1071
typedef struct pdf_data_writer_s {
1072
psdf_binary_writer binary;
1075
pdf_resource_t *pres;
1076
gx_device_pdf *pdev; /* temporary for backward compatibility of pdf_end_data prototype. */
1079
} pdf_data_writer_t;
1081
* Begin a data stream. The client has opened the object and written
1082
* the << and any desired dictionary keys.
1084
#define DATA_STREAM_NOT_BINARY 0 /* data are text, not binary */
1085
#define DATA_STREAM_BINARY 1 /* data are binary */
1086
#define DATA_STREAM_COMPRESS 2 /* OK to compress data */
1087
#define DATA_STREAM_NOLENGTH 4 /* Skip the length reference and filter names writing. */
1088
#define DATA_STREAM_ENCRYPT 8 /* Encrypt data. */
1089
int pdf_begin_data_stream(gx_device_pdf *pdev, pdf_data_writer_t *pdw,
1090
int options, gs_id object_id);
1091
int pdf_append_data_stream_filters(gx_device_pdf *pdev, pdf_data_writer_t *pdw,
1092
int orig_options, gs_id object_id);
1093
/* begin_data = begin_data_binary with both options = true. */
1094
int pdf_begin_data(gx_device_pdf *pdev, pdf_data_writer_t *pdw);
1096
/* End a data stream. */
1097
int pdf_end_data(pdf_data_writer_t *pdw);
1099
/* ------ Functions ------ */
1101
/* Define the maximum size of a Function reference. */
1102
#define MAX_REF_CHARS ((sizeof(long) * 8 + 2) / 3)
1105
* Create a Function object with or without range scaling. Scaling means
1106
* that if x[i] is the i'th output value from the original Function,
1107
* the i'th output value from the Function object will be (x[i] -
1108
* ranges[i].rmin) / (ranges[i].rmax - ranges[i].rmin). Note that this is
1109
* the inverse of the scaling convention for Functions per se.
1111
#ifndef gs_function_DEFINED
1112
typedef struct gs_function_s gs_function_t;
1113
# define gs_function_DEFINED
1115
int pdf_function(gx_device_pdf *pdev, const gs_function_t *pfn,
1116
cos_value_t *pvalue);
1117
int pdf_function_scaled(gx_device_pdf *pdev, const gs_function_t *pfn,
1118
const gs_range_t *pranges, cos_value_t *pvalue);
1120
/* Write a Function object, returning its object ID. */
1121
int pdf_write_function(gx_device_pdf *pdev, const gs_function_t *pfn,
1124
/* ------ Fonts ------ */
1126
/* Write a FontBBox dictionary element. */
1127
int pdf_write_font_bbox(gx_device_pdf *pdev, const gs_int_rect *pbox);
1128
int pdf_write_font_bbox_float(gx_device_pdf *pdev, const gs_rect *pbox);
1130
/* ---------------- Exported by gdevpdfm.c ---------------- */
1133
* Define the type for a pdfmark-processing procedure.
1134
* If nameable is false, the objname argument is always NULL.
1136
#define pdfmark_proc(proc)\
1137
int proc(gx_device_pdf *pdev, gs_param_string *pairs, uint count,\
1138
const gs_matrix *pctm, const gs_param_string *objname)
1140
/* Compare a C string and a gs_param_string. */
1141
bool pdf_key_eq(const gs_param_string * pcs, const char *str);
1143
/* Scan an integer out of a parameter string. */
1144
int pdfmark_scan_int(const gs_param_string * pstr, int *pvalue);
1146
/* Process a pdfmark (called from pdf_put_params). */
1147
int pdfmark_process(gx_device_pdf * pdev, const gs_param_string_array * pma);
1149
/* Close the current level of the outline tree. */
1150
int pdfmark_close_outline(gx_device_pdf * pdev);
1152
/* Close the pagelabel numtree. */
1153
int pdfmark_end_pagelabels(gx_device_pdf * pdev);
1155
/* Finish writing an article. */
1156
int pdfmark_write_article(gx_device_pdf * pdev, const pdf_article_t * part);
1158
/* ---------------- Exported by gdevpdfr.c ---------------- */
1160
/* Test whether an object name has valid syntax, {name}. */
1161
bool pdf_objname_is_valid(const byte *data, uint size);
1164
* Look up a named object. Return e_rangecheck if the syntax is invalid,
1165
* e_undefined if no object by that name exists.
1167
int pdf_find_named(gx_device_pdf * pdev, const gs_param_string * pname,
1168
cos_object_t **ppco);
1171
* Create a named object. id = -1L means do not assign an id. pname = 0
1172
* means just create the object, do not name it.
1174
int pdf_create_named(gx_device_pdf *pdev, const gs_param_string *pname,
1175
cos_type_t cotype, cos_object_t **ppco, long id);
1176
int pdf_create_named_dict(gx_device_pdf *pdev, const gs_param_string *pname,
1177
cos_dict_t **ppcd, long id);
1180
* Look up a named object as for pdf_find_named. If the object does not
1181
* exist, create it (as a dictionary if it is one of the predefined names
1182
* {ThisPage}, {NextPage}, {PrevPage}, or {Page<#>}, otherwise as a
1183
* generic object) and return 1.
1185
int pdf_refer_named(gx_device_pdf *pdev, const gs_param_string *pname,
1186
cos_object_t **ppco);
1189
* Look up a named object as for pdf_refer_named. If the object already
1190
* exists and is not simply a forward reference, return e_rangecheck;
1191
* if it exists as a forward reference, set its type and return 0;
1192
* otherwise, create the object with the given type and return 1.
1193
* pname = 0 is allowed: in this case, simply create the object.
1195
int pdf_make_named(gx_device_pdf * pdev, const gs_param_string * pname,
1196
cos_type_t cotype, cos_object_t **ppco, bool assign_id);
1197
int pdf_make_named_dict(gx_device_pdf * pdev, const gs_param_string * pname,
1198
cos_dict_t **ppcd, bool assign_id);
1201
* Look up a named object as for pdf_refer_named. If the object does not
1202
* exist, or is a forward reference, return e_undefined; if the object
1203
* exists has the wrong type, return e_typecheck.
1205
int pdf_get_named(gx_device_pdf * pdev, const gs_param_string * pname,
1206
cos_type_t cotype, cos_object_t **ppco);
1209
* Push the current local namespace onto the namespace stack, and reset it
1210
* to an empty namespace.
1212
int pdf_push_namespace(gx_device_pdf *pdev);
1215
* Pop the top local namespace from the namespace stack. Return an error if
1216
* the stack is empty.
1218
int pdf_pop_namespace(gx_device_pdf *pdev);
1221
* Scan a string for a token. <<, >>, [, and ] are treated as tokens.
1222
* Return 1 if a token was scanned, 0 if we reached the end of the string,
1223
* or an error. On a successful return, the token extends from *ptoken up
1224
* to but not including *pscan.
1226
int pdf_scan_token(const byte **pscan, const byte * end, const byte **ptoken);
1229
* Scan a possibly composite token: arrays and dictionaries are treated as
1232
int pdf_scan_token_composite(const byte **pscan, const byte * end,
1233
const byte **ptoken);
1235
/* Replace object names with object references in a (parameter) string. */
1236
int pdf_replace_names(gx_device_pdf *pdev, const gs_param_string *from,
1237
gs_param_string *to);
1239
/* ================ Text module procedures ================ */
1241
/* ---------------- Exported by gdevpdfw.c ---------------- */
1246
* Close the text-related parts of a document, including writing out font
1247
* and related resources.
1249
int pdf_close_text_document(gx_device_pdf *pdev);
1251
/* ---------------- Exported by gdevpdft.c ---------------- */
1255
pdf_text_data_t *pdf_text_data_alloc(gs_memory_t *mem);
1256
void pdf_set_text_state_default(pdf_text_state_t *pts);
1257
void pdf_text_state_copy(pdf_text_state_t *pts_to, pdf_text_state_t *pts_from);
1258
void pdf_reset_text_page(pdf_text_data_t *ptd);
1259
void pdf_reset_text_state(pdf_text_data_t *ptd);
1260
void pdf_close_text_page(gx_device_pdf *pdev);
1261
int pdf_get_stoted_text_size(pdf_text_state_t *state);
1263
/* For gdevpdfb.c */
1265
int pdf_char_image_y_offset(const gx_device_pdf *pdev, int x, int y, int h);
1267
/* Begin a CharProc for an embedded (bitmap) font. */
1268
int pdf_begin_char_proc(gx_device_pdf * pdev, int w, int h, int x_width,
1269
int y_offset, int x_offset, gs_id id, pdf_char_proc_t **ppcp,
1270
pdf_stream_position_t * ppos);
1272
/* End a CharProc. */
1273
int pdf_end_char_proc(gx_device_pdf * pdev, pdf_stream_position_t * ppos);
1275
/* Put out a reference to an image as a character in an embedded font. */
1276
int pdf_do_char_image(gx_device_pdf * pdev, const pdf_char_proc_t * pcp,
1277
const gs_matrix * pimat);
1279
/* Start charproc accumulation for a Type 3 font. */
1280
int pdf_start_charproc_accum(gx_device_pdf *pdev);
1281
/* Install charproc accumulator for a Type 3 font. */
1282
int pdf_set_charproc_attrs(gx_device_pdf *pdev, gs_font *font, double *pw, int narg,
1283
gs_text_cache_control_t control, gs_char ch, bool scale_100);
1284
/* Complete charproc accumulation for aType 3 font. */
1285
int pdf_end_charproc_accum(gx_device_pdf *pdev, gs_font *font, const pdf_char_glyph_pairs_t *cgp,
1286
gs_glyph glyph, gs_char output_char_code, const gs_const_string *gnstr);
1287
/* Open a stream object in the temporary file. */
1288
int pdf_open_aside(gx_device_pdf *pdev, pdf_resource_type_t rtype,
1289
gs_id id, pdf_resource_t **ppres, bool reserve_object_id, int options);
1291
/* Close a stream object in the temporary file. */
1292
int pdf_close_aside(gx_device_pdf *pdev);
1294
/* Enter the substream accumulation mode. */
1295
int pdf_enter_substream(gx_device_pdf *pdev, pdf_resource_type_t rtype,
1296
gs_id id, pdf_resource_t **ppres, bool reserve_object_id, bool compress);
1298
/* Exit the substream accumulation mode. */
1299
int pdf_exit_substream(gx_device_pdf *pdev);
1300
/* Add procsets to substream Resources. */
1301
int pdf_add_procsets(cos_dict_t *pcd, pdf_procset_t procsets);
1302
/* Add a resource to substream Resources. */
1303
int pdf_add_resource(gx_device_pdf *pdev, cos_dict_t *pcd, const char *key, pdf_resource_t *pres);
1305
/* For gdevpdfu.c */
1307
int pdf_from_stream_to_text(gx_device_pdf *pdev);
1308
int pdf_from_string_to_text(gx_device_pdf *pdev);
1309
void pdf_close_text_contents(gx_device_pdf *pdev);
1311
#endif /* gdevpdfx_INCLUDED */