Thu, 20 Mar 2003 07:06:35 +0000
*** empty log message ***
1 /*
2 * tumble: build a PDF file from image files
3 *
4 * PDF routines
5 * $Id: pdf_prim.h,v 1.10 2003/03/13 00:57:05 eric Exp $
6 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. Note that permission is
11 * not granted to redistribute this program under the terms of any
12 * other version of the General Public License.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
22 */
25 typedef enum
26 {
27 PT_BAD,
29 /* scalar */
30 PT_NULL,
31 PT_BOOL,
32 PT_NAME,
33 PT_STRING,
34 PT_INTEGER,
35 PT_REAL,
36 PT_IND_REF,
38 /* composite */
39 PT_DICTIONARY,
40 PT_ARRAY,
41 PT_STREAM
42 } pdf_obj_type;
45 struct pdf_obj;
48 typedef void (*pdf_stream_write_callback)(pdf_file_handle pdf_file,
49 struct pdf_obj *stream,
50 void *app_data);
53 /* returns -1 if o1 < 02, 0 if o1 == o2, 1 if o1 > o2 */
54 /* only works for integer, real, string, and name objects */
55 int pdf_compare_obj (struct pdf_obj *o1, struct pdf_obj *o2);
58 void pdf_set_dict_entry (struct pdf_obj *dict_obj, char *key, struct pdf_obj *val);
59 struct pdf_obj *pdf_get_dict_entry (struct pdf_obj *dict_obj, char *key);
62 void pdf_add_array_elem (struct pdf_obj *array_obj, struct pdf_obj *val);
65 /* Following is intended for things like ProcSet in which an array object
66 is used to represent a set. Only works if all objects in array, and
67 the element to be added are of scalar types (types that are supported
68 by pdf_compare_obj. Not efficient for large arrays as it does a
69 comaprison to every element. */
70 void pdf_add_array_elem_unique (struct pdf_obj *array_obj, struct pdf_obj *val);
73 /* Create a new object that will NOT be used indirectly */
74 struct pdf_obj *pdf_new_obj (pdf_obj_type type);
76 struct pdf_obj *pdf_new_bool (bool val);
78 struct pdf_obj *pdf_new_name (char *name);
80 struct pdf_obj *pdf_new_string (char *str);
82 struct pdf_obj *pdf_new_integer (long val);
84 struct pdf_obj *pdf_new_real (double val);
87 /* Create a new indirect object */
88 struct pdf_obj *pdf_new_ind_ref (pdf_file_handle pdf_file, struct pdf_obj *obj);
90 /* get the object referenced by an indirect reference */
91 struct pdf_obj *pdf_deref_ind_obj (struct pdf_obj *ind_obj);
94 long pdf_get_integer (struct pdf_obj *obj);
95 void pdf_set_integer (struct pdf_obj *obj, long val);
98 double pdf_get_real (struct pdf_obj *obj);
99 void pdf_set_real (struct pdf_obj *obj, double val);
102 /* The callback will be called when the stream data is to be written to the
103 file. app_data will be passed as an argument to the callback. */
104 struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file,
105 struct pdf_obj *stream_dict,
106 pdf_stream_write_callback callback,
107 void *app_data);
109 /* The callback should call pdf_stream_write_data() or pdf_stream_printf()
110 to write the actual stream data. */
112 void pdf_stream_flush_bits (pdf_file_handle pdf_file,
113 struct pdf_obj *stream);
115 void pdf_stream_write_data (pdf_file_handle pdf_file,
116 struct pdf_obj *stream,
117 char *data,
118 unsigned long len);
120 void pdf_stream_printf (pdf_file_handle pdf_file,
121 struct pdf_obj *stream,
122 char *fmt, ...);
125 void pdf_stream_add_filter (struct pdf_obj *stream,
126 char *filter_name,
127 struct pdf_obj *decode_parms);
130 /* Write the object to the file */
131 void pdf_write_obj (pdf_file_handle pdf_file, struct pdf_obj *obj);
134 /* Write the indirect object to the file. For most objects this should
135 be done by pdf_write_all_ind_obj() when the file is being closed, but for
136 large objects such as streams, it's probably better to do it as soon as the
137 object is complete. */
138 void pdf_write_ind_obj (pdf_file_handle pdf_file, struct pdf_obj *ind_obj);
141 /* Write all indirect objects that haven't already been written to the file. */
142 void pdf_write_all_ind_obj (pdf_file_handle pdf_file);
145 /* Write the cross reference table, and return the maximum object number */
146 unsigned long pdf_write_xref (pdf_file_handle pdf_file);
149 /* this isn't really a PDF primitive data type */
150 char pdf_new_XObject (pdf_page_handle pdf_page, struct pdf_obj *ind_ref);