3
Copyright 2009 Taco Hoekwater <taco@luatex.org>
5
This file is part of LuaTeX.
7
LuaTeX is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 2 of the License, or (at your
10
option) any later version.
12
LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15
License for more details.
17
You should have received a copy of the GNU General Public License along
18
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
20
/* $Id: pdftypes.h 3275 2009-12-20 22:20:08Z hhenkel $ */
27
/* This stucture holds everything that is needed for the actual pdf generation.
29
Because this structure interfaces with C++, it is not wise to use |boolean|
30
here (C++ has a boolean type built-in that is not compatible). Also, I have
31
plans to convert the backend code into a C library for use with e.g. standalone
32
lua. Together, this means that it is best only to use the standard C types and
33
the types explicitly defined in this header, and stay away from types like
34
|integer| and |eight_bits| that are used elsewhere in the \LUATEX\ sources.
38
typedef struct os_obj_data_ {
44
long m; /* mantissa (significand) */
45
int e; /* exponent * -1 */
55
typedef struct scaledpos_ {
60
typedef struct scaled_whd_ {
61
scaled wd; /* TeX width */
62
scaled ht; /* TeX height */
63
scaled dp; /* TeX depth */
66
typedef struct posstructure_ {
67
scaledpos pos; /* position on the page */
68
int dir; /* direction of stuff to be put onto the page */
72
scaledpos curpos; /* \pdflastpos position */
73
posstructure boxpos; /* box dir and position of the box origin on the page */
74
scaled_whd boxdim; /* box dimensions (in hlist/vlist coordinate system) */
77
typedef enum { PMODE_NONE, PMODE_PAGE, PMODE_TEXT, PMODE_CHARARRAY, PMODE_CHAR
80
typedef enum { OMODE_NONE, OMODE_DVI, OMODE_PDF, OMODE_LUA } output_mode;
82
# define MAX_OMODE 3 /* largest index in enum output_mode */
84
typedef enum { ST_INITIAL, ST_OMODE_FIX, ST_FILE_OPEN, ST_HEADER_WRITTEN,
88
typedef struct pdf_object_list_ {
90
struct pdf_object_list_ *link;
93
typedef enum { WMODE_H, WMODE_V } writing_mode; /* []TJ runs horizontal or vertical */
96
pdfpos pdf; /* pos. on page (PDF page raster) */
97
pdfpos pdf_bt_pos; /* pos. at begin of BT-ET group (PDF page raster) */
98
pdfpos pdf_tj_pos; /* pos. at begin of TJ array (PDF page raster) */
99
pdffloat cw; /* pos. within [(..)..]TJ array (glyph raster);
100
cw.e = fractional digits in /Widths array */
101
pdffloat tj_delta; /* rel. movement in [(..)..]TJ array (glyph raster) */
102
pdffloat fs; /* font size in PDF units */
103
pdffloat fs_cur; /* to check if fs.m has changed and Tf needed */
104
pdffloat cm[6]; /* cm array */
105
pdffloat tm[6]; /* Tm array */
106
double k1; /* conv. factor from TeX sp to PDF page raster */
107
double k2; /* conv. factor from PDF page raster to TJ array raster */
108
int f_pdf; /* /F* font number, of unexpanded base font! */
109
int f_pdf_cur; /* to check if f_pdf has changed and Tf needed */
110
writing_mode wmode; /* PDF writing mode WMode (horizontal/vertical) */
111
pos_mode mode; /* current positioning mode */
112
int ishex; /* Whether the current char string is <> or () */
115
typedef struct obj_entry_ {
127
int objtype; /* integer int5 */
130
typedef struct dest_name_entry_ {
131
char *objname; /* destination name */
132
int objnum; /* destination object number */
135
# define pdf_max_link_level 10 /* maximum depth of link nesting */
137
typedef struct pdf_link_stack_record {
139
int link_node; /* holds a copy of the corresponding |pdf_start_link_node| */
140
int ref_link_node; /* points to original |pdf_start_link_node|, or a
141
copy of |link_node| created by |append_link| in
142
case of multi-line link */
143
} pdf_link_stack_record;
145
/* types of objects */
147
obj_type_font = 0, /* index of linked list of Fonts objects */
148
obj_type_outline = 1, /* index of linked list of outline objects */
149
obj_type_dest = 2, /* index of linked list of destination objects */
150
obj_type_obj = 3, /* index of linked list of raw objects */
151
obj_type_xform = 4, /* index of linked list of XObject forms */
152
obj_type_ximage = 5, /* index of linked list of XObject images */
153
obj_type_thread = 6, /* index of linked list of num article threads */
154
/* |obj_type_thread| is the highest entry in |head_tab|, but there are a few
155
more linked lists that are handy: */
156
obj_type_pagestream = 7, /* Page stream objects */
157
obj_type_page = 8, /* Page objects */
158
obj_type_pages = 9, /* Pages objects */
159
obj_type_link = 10, /* link objects */
160
obj_type_bead = 11, /* thread bead objects */
161
obj_type_annot = 12, /* annotation objects */
162
obj_type_objstm = 13, /* /ObjStm objects */
163
obj_type_others = 14 /* any other objects (also not linked in any list) */
166
# define HEAD_TAB_MAX 6 /* obj_type_thread */
167
# define PDF_OBJ_TYPE_MAX 14 /* obj_type_others */
169
typedef struct pdf_resource_struct_ {
170
pdf_object_list *font_list; /* |font_list| during flushing pending forms */
171
pdf_object_list *dest_list; /* the pdf destinations */
172
pdf_object_list *obj_list; /* |pdf_obj_list| */
173
pdf_object_list *xform_list; /* |pdf_xform_list| */
174
pdf_object_list *ximage_list; /* |pdf_ximage_list| */
175
pdf_object_list *link_list; /* the pdf links */
176
pdf_object_list *bead_list; /* the thread beads */
177
pdf_object_list *annot_list; /* the pdf annotations */
178
int text_procset; /* |pdf_text_procset| */
179
int image_procset; /* |pdf_image_procset| */
180
int last_resources; /* halfword to most recently generated Resources object. */
181
} pdf_resource_struct;
183
typedef struct pdf_output_file_ {
184
FILE *file; /* the PDF output file handle */
185
char *file_name; /* the PDF output file name */
186
output_mode o_mode; /* output mode (DVI/PDF/...) */
187
output_state o_state;
188
/* generation parameters */
191
int image_hicolor; /* boolean */
192
int image_apply_gamma;
197
int inclusion_copy_font;
199
int minor_version; /* fixed minor part of the PDF version */
200
int compress_level; /* level for zlib object stream compression */
201
int objcompresslevel; /* fixed level for activating PDF object streams */
202
char *job_id_string; /* the full job string */
204
/* output file buffering */
205
unsigned char *op_buf; /* the PDF output buffer */
206
int op_buf_size; /* output buffer size (static) */
207
int op_ptr; /* store for PDF buffer |pdf_ptr| while inside object streams */
208
unsigned char *os_buf; /* the PDF object stream buffer */
209
int os_buf_size; /* current size of the PDF object stream buffer, grows dynamically */
210
int os_ptr; /* store for object stream |pdf_ptr| while outside object streams */
212
os_obj_data *os_obj; /* array of object stream objects */
213
int os_idx; /* pointer into |pdf_os_objnum| and |pdf_os_objoff| */
214
int os_cntr; /* counter for object stream objects */
215
int os_mode; /* true if producing object stream */
216
int os_enable; /* true if object streams are globally enabled */
217
int os_cur_objnum; /* number of current object stream object */
219
unsigned char *buf; /* pointer to the PDF output buffer or PDF object stream buffer */
220
int buf_size; /* end of PDF output buffer or PDF object stream buffer */
221
int ptr; /* pointer to the first unused byte in the PDF buffer or object stream buffer */
222
off_t save_offset; /* to save |pdf_offset| */
223
off_t gone; /* number of bytes that were flushed to output */
225
char *printf_buf; /* a scratch buffer for |pdf_printf| */
227
time_t start_time; /* when this job started */
228
char *start_time_str; /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */
230
/* define fb_ptr, fb_array & fb_limit */
236
z_stream c_stream; /* compression stream */
237
int zip_write_state; /* which state of compression we are in */
239
int pk_scale_factor; /* this is just a preprocessed value that depends on
240
|pk_resolution| and |decimal_digits| */
242
int img_page_group_val; /* page group information pointer from included pdf or png images */
243
char *resname_prefix; /* global prefix of resources name */
245
int mem_size; /* allocated size of |mem| array */
249
pdfstructure *pstruct; /* utity structure keeping position status in PDF page stream */
250
posstructure *posstruct; /* structure for positioning within page */
252
int obj_tab_size; /* allocated size of |obj_tab| array */
254
int head_tab[HEAD_TAB_MAX + 1]; /* heads of the object lists in |obj_tab| */
255
struct avl_table *obj_tree[PDF_OBJ_TYPE_MAX + 1]; /* this is useful for finding the objects back */
258
int obj_ptr; /* user objects counter */
259
int sys_obj_ptr; /* system objects counter, including object streams */
260
int last_pages; /* pointer to most recently generated pages object */
261
int last_page; /* pointer to most recently generated page object */
262
int last_stream; /* pointer to most recently generated stream */
263
off_t stream_length; /* length of most recently generated stream */
264
off_t stream_length_offset; /* file offset of the last stream length */
265
int seek_write_length; /* flag whether to seek back and write \.{/Length} */
266
int last_byte; /* byte most recently written to PDF file; for \.{endstream} in new line */
268
/* integer last_resources; halfword to most recently generated Resources object.
269
TH: this used to be a local in pdf_shipout, but I would like to
270
be able to split that function into a pre- and post part */
276
pdf_resource_struct *resources;
278
/* the variables from pdfdest */
281
dest_name_entry *dest_names;
282
/* the (static) variables from pdfoutline */
286
/* the pdf link stack */
287
pdf_link_stack_record link_stack[(pdf_max_link_level + 1)];
289
/* the thread data */
290
int last_thread; /* pointer to the last thread */
292
int last_thread_id; /* identifier of the last thread */
293
int last_thread_named_id; /* is identifier of the last thread named */
294
int thread_level; /* depth of nesting of box containing the last thread */
296
int f_cur; /* TeX font number */
299
typedef pdf_output_file *PDF;