pdf_prim.h

Thu, 20 Feb 2003 12:16:00 +0000

author
eric
date
Thu, 20 Feb 2003 12:16:00 +0000
changeset 59
e8821eb2fb08
child 62
9bd354b83e16
permissions
-rw-r--r--

my own PDF routines to replace Panda.

eric@59 1 typedef enum
eric@59 2 {
eric@59 3 PT_BAD,
eric@59 4
eric@59 5 /* scalar */
eric@59 6 PT_NULL,
eric@59 7 PT_BOOL,
eric@59 8 PT_NAME,
eric@59 9 PT_STRING,
eric@59 10 PT_INTEGER,
eric@59 11 PT_REAL,
eric@59 12 PT_IND_REF,
eric@59 13
eric@59 14 /* composite */
eric@59 15 PT_DICTIONARY,
eric@59 16 PT_ARRAY,
eric@59 17 PT_STREAM
eric@59 18 } pdf_obj_type;
eric@59 19
eric@59 20
eric@59 21 struct pdf_obj;
eric@59 22
eric@59 23
eric@59 24 typedef void (*pdf_stream_write_callback)(pdf_file_handle pdf_file,
eric@59 25 struct pdf_obj *stream,
eric@59 26 void *app_data);
eric@59 27
eric@59 28
eric@59 29 void pdf_set_dict_entry (struct pdf_obj *dict_obj, char *key, struct pdf_obj *val);
eric@59 30 struct pdf_obj *pdf_get_dict_entry (struct pdf_obj *dict_obj, char *key);
eric@59 31
eric@59 32
eric@59 33 void pdf_add_array_elem (struct pdf_obj *array_obj, struct pdf_obj *val);
eric@59 34
eric@59 35
eric@59 36 /* Create a new object that will NOT be used indirectly */
eric@59 37 struct pdf_obj *pdf_new_obj (pdf_obj_type type);
eric@59 38
eric@59 39 struct pdf_obj *pdf_new_bool (int bool);
eric@59 40
eric@59 41 struct pdf_obj *pdf_new_name (char *name);
eric@59 42
eric@59 43 struct pdf_obj *pdf_new_string (char *str);
eric@59 44
eric@59 45 struct pdf_obj *pdf_new_integer (unsigned long val);
eric@59 46
eric@59 47 struct pdf_obj *pdf_new_real (double val);
eric@59 48
eric@59 49
eric@59 50 /* Create a new indirect object */
eric@59 51 struct pdf_obj *pdf_new_ind_ref (pdf_file_handle pdf_file, struct pdf_obj *obj);
eric@59 52
eric@59 53 /* get the object referenced by an indirect reference */
eric@59 54 struct pdf_obj *pdf_deref_ind_obj (struct pdf_obj *ind_obj);
eric@59 55
eric@59 56
eric@59 57 unsigned long pdf_get_integer (struct pdf_obj *obj);
eric@59 58 void pdf_set_integer (struct pdf_obj *obj, unsigned long val);
eric@59 59
eric@59 60
eric@59 61 double pdf_get_real (struct pdf_obj *obj);
eric@59 62 void pdf_set_real (struct pdf_obj *obj, double val);
eric@59 63
eric@59 64
eric@59 65 /* The callback will be called when the stream data is to be written to the
eric@59 66 file. app_data will be passed as an argument to the callback. */
eric@59 67 struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file,
eric@59 68 struct pdf_obj *stream_dict,
eric@59 69 pdf_stream_write_callback callback,
eric@59 70 void *app_data);
eric@59 71
eric@59 72 /* The callback should call pdf_stream_write_data to write the actual
eric@59 73 stream data. */
eric@59 74 void pdf_stream_write_data (pdf_file_handle pdf_file,
eric@59 75 struct pdf_obj *stream,
eric@59 76 char *data,
eric@59 77 unsigned long len);
eric@59 78
eric@59 79 void pdf_stream_add_filter (struct pdf_obj *stream,
eric@59 80 char *filter_name,
eric@59 81 struct pdf_obj *decode_parms);
eric@59 82
eric@59 83
eric@59 84 /* Write the object to the file */
eric@59 85 void pdf_write_obj (pdf_file_handle pdf_file, struct pdf_obj *obj);
eric@59 86
eric@59 87
eric@59 88 /* Write the indirect object to the file. For most objects this should
eric@59 89 be done by pdf_write_all_ind_obj() when the file is being closed, but for
eric@59 90 large objects such as streams, it's probably better to do it as soon as the
eric@59 91 object is complete. */
eric@59 92 void pdf_write_ind_obj (pdf_file_handle pdf_file, struct pdf_obj *ind_obj);
eric@59 93
eric@59 94
eric@59 95 /* Write all indirect objects that haven't already been written to the file. */
eric@59 96 void pdf_write_all_ind_obj (pdf_file_handle pdf_file);
eric@59 97
eric@59 98
eric@59 99 /* Write the cross reference table, and return the maximum object number */
eric@59 100 unsigned long pdf_write_xref (pdf_file_handle pdf_file);