3 Copyright 2009-2013 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/>. */
25 # define PROCSET_PDF (1 << 0)
26 # define PROCSET_TEXT (1 << 1)
27 # define PROCSET_IMAGE_B (1 << 2)
28 # define PROCSET_IMAGE_C (1 << 3)
29 # define PROCSET_IMAGE_I (1 << 4)
31 # define inf_pdf_mem_size 10000/* min size of the |mem| array */
32 # define sup_pdf_mem_size 10000000 /* max size of the |mem| array */
34 extern PDF static_pdf
;
36 extern int pdf_get_mem(PDF pdf
, int s
);
39 We use the similiar subroutines to handle the output buffer for
40 PDF output. When compress is used, the state of writing to buffer
41 is held in |zip_write_state|. We must write the header of PDF
42 output file in initialization to ensure that it will be the first
46 # define inf_pdfout_buf_size 16384 /* initial value of |pdf->buf| size */
47 # define sup_pdfout_buf_size 16384 /* arbitrary upper hard limit of |pdf->buf| size */
48 # define inf_objstm_buf_size 1 /* initial value of |os->buf[OBJSTM_BUF]| size */
49 # define sup_objstm_buf_size 5000000 /* arbitrary upper hard limit of |os->buf[OBJSTM_BUF]| size */
51 # define PDF_OS_MAX_OBJS 100 /* maximum number of objects in object stream */
53 # define inf_obj_tab_size 1000 /* min size of the cross-reference table for PDF output */
54 # define sup_obj_tab_size 8388607 /* max size of the cross-reference table for PDF output */
56 /* The following macros are similar as for \.{DVI} buffer handling */
58 # define pdf_offset(pdf) (pdf->gone + (off_t)(pdf->buf->p - pdf->buf->data))
59 /* the file offset of last byte in PDF
60 buffer that |pdf_ptr| points to */
61 # define pdf_save_offset(pdf) pdf->save_offset = (pdf->gone + (off_t)(pdf->buf->p - pdf->buf->data))
63 # define set_ff(A) do { \
64 if (pdf_font_num(A) < 0) \
65 ff = -pdf_font_num(A); \
70 typedef enum { NOT_SHIPPING
, SHIPPING_PAGE
, SHIPPING_FORM
} shipping_mode_e
;
72 extern int pdf_output_option
;
73 extern int pdf_output_value
;
74 extern int pdf_draftmode_option
;
75 extern int pdf_draftmode_value
;
77 extern scaled one_hundred_inch
;
78 extern scaled one_inch
;
79 extern scaled one_true_inch
;
80 extern scaled one_hundred_bp
;
82 extern int ten_pow
[10];
84 extern void pdf_flush(PDF
);
85 extern void pdf_room(PDF
, int);
87 extern void fix_pdf_minorversion(PDF
);
89 /* output a byte to PDF buffer without checking of overflow */
90 # define pdf_quick_out(pdf,A) * (pdf->buf->p++) = (unsigned char) (A)
92 /* do the same as |pdf_quick_out| and flush the PDF buffer if necessary */
93 # define pdf_out(pdf,A) do { pdf_room(pdf, 1); pdf_quick_out(pdf, A); } while (0)
96 Basic printing procedures for PDF output are very similiar to \TeX\ basic
97 printing ones but the output is going to PDF buffer. Subroutines with
98 suffix |_ln| append a new-line character to the PDF output.
101 /* print out a string to PDF buffer followed by a new-line character */
102 # define pdf_print_ln(pdf,A) do { \
104 pdf_out(pdf, '\n'); \
107 /* print out an integer to PDF buffer followed by a new-line character */
108 # define pdf_print_int_ln(pdf,A) do { \
109 pdf_print_int(pdf,A); \
110 pdf_out(pdf, '\n'); \
113 extern __attribute__ ((format(printf
, 2, 3)))
114 void pdf_printf(PDF
, const char *, ...);
116 extern void pdf_print(PDF
, str_number
);
117 extern void pdf_print_int(PDF
, longinteger
);
118 extern void print_pdffloat(PDF pdf
, pdffloat f
);
119 extern void pdf_print_str(PDF
, const char *);
121 extern void pdf_add_null(PDF
);
122 extern void pdf_add_bool(PDF
, int i
);
123 extern void pdf_add_int(PDF
, int i
);
124 extern void pdf_add_longint(PDF
, longinteger n
);
125 extern void pdf_add_ref(PDF
, int num
);
126 extern void pdf_add_string(PDF
, const char *s
);
127 extern void pdf_add_name(PDF
, const char *name
);
129 extern void pdf_dict_add_bool(PDF
, const char *key
, int i
);
130 extern void pdf_dict_add_int(PDF
, const char *key
, int i
);
131 extern void pdf_dict_add_ref(PDF
, const char *key
, int num
);
132 extern void pdf_dict_add_name(PDF
, const char *key
, const char *val
);
133 extern void pdf_dict_add_string(PDF pdf
, const char *key
, const char *val
);
134 extern void pdf_dict_add_streaminfo(PDF
);
136 extern void pdf_begin_stream(PDF
);
137 extern void pdf_end_stream(PDF
);
139 extern void pdf_add_bp(PDF
, scaled
);
140 extern void pdf_add_mag_bp(PDF
, scaled
);
142 extern strbuf_s
*new_strbuf(size_t size
, size_t limit
);
143 extern void strbuf_seek(strbuf_s
* b
, off_t offset
);
144 extern size_t strbuf_offset(strbuf_s
* b
);
145 extern void strbuf_putchar(strbuf_s
* b
, unsigned char c
);
146 extern void strbuf_flush(PDF pdf
, strbuf_s
* b
);
147 extern void strbuf_free(strbuf_s
* b
);
149 /* This is for the resource lists */
151 extern void addto_page_resources(PDF pdf
, pdf_obj_type t
, int k
);
152 extern pdf_object_list
*get_page_resources_list(PDF pdf
, pdf_obj_type t
);
154 extern void pdf_out_block(PDF pdf
, const char *s
, size_t n
);
156 # define pdf_puts(pdf, s) pdf_out_block((pdf), (s), strlen(s))
158 # define pdf_print_resname_prefix(pdf) do { \
159 if (pdf->resname_prefix != NULL) \
160 pdf_puts(pdf, pdf->resname_prefix); \
163 extern void pdf_print_str_ln(PDF
, const char *);
165 extern void pdf_print_toks(PDF
, halfword
);
167 extern void pdf_add_rect_spec(PDF
, halfword
);
168 extern void pdf_rectangle(PDF
, halfword
);
170 extern void pdf_begin_obj(PDF
, int, int);
171 extern void pdf_end_obj(PDF
);
173 extern void pdf_begin_dict(PDF
);
174 extern void pdf_end_dict(PDF
);
175 extern void pdf_begin_array(PDF
);
176 extern void pdf_end_array(PDF
);
178 extern void remove_pdffile(PDF
);
180 extern void zip_free(PDF
);
182 /* functions that do not output stuff */
184 extern scaled
round_xn_over_d(scaled x
, int n
, unsigned int d
);
186 extern char *convertStringToPDFString(const char *in
, int len
);
188 extern void init_start_time(PDF
);
189 extern char *getcreationdate(PDF
);
191 extern void pdf_error(const char *t
, const char *p
);
192 extern void pdf_warning(const char *t
, const char *p
, boolean pr
, boolean ap
);
193 extern void check_o_mode(PDF pdf
, const char *s
, int o_mode
, boolean errorflag
);
195 extern void set_job_id(PDF
, int, int, int, int);
196 extern char *get_resname_prefix(PDF
);
197 extern void pdf_begin_page(PDF pdf
);
198 extern void pdf_end_page(PDF pdf
);
199 extern void print_pdf_table_string(PDF pdf
, const char *s
);
200 extern char *get_pdf_table_string(const char *s
);
201 extern int get_pdf_table_bool(PDF
, const char *, int);
203 extern void fix_o_mode(PDF pdf
);
204 extern void ensure_output_state(PDF pdf
, output_state s
);
205 extern PDF
init_pdf_struct(PDF pdf
);
207 extern halfword pdf_info_toks
; /* additional keys of Info dictionary */
208 extern halfword pdf_catalog_toks
; /* additional keys of Catalog dictionary */
209 extern halfword pdf_catalog_openaction
;
210 extern halfword pdf_names_toks
; /* additional keys of Names dictionary */
211 extern halfword pdf_trailer_toks
; /* additional keys of Trailer dictionary */
212 extern void scan_pdfcatalog(PDF pdf
);
213 extern void finish_pdf_file(PDF pdf
, int luatex_version
,
214 str_number luatex_revision
);
216 extern shipping_mode_e global_shipping_mode
;
218 #endif /* PDFGEN_H */