1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/pdf_prim.h Thu Feb 20 12:16:00 2003 +0000 1.3 @@ -0,0 +1,100 @@ 1.4 +typedef enum 1.5 +{ 1.6 + PT_BAD, 1.7 + 1.8 + /* scalar */ 1.9 + PT_NULL, 1.10 + PT_BOOL, 1.11 + PT_NAME, 1.12 + PT_STRING, 1.13 + PT_INTEGER, 1.14 + PT_REAL, 1.15 + PT_IND_REF, 1.16 + 1.17 + /* composite */ 1.18 + PT_DICTIONARY, 1.19 + PT_ARRAY, 1.20 + PT_STREAM 1.21 +} pdf_obj_type; 1.22 + 1.23 + 1.24 +struct pdf_obj; 1.25 + 1.26 + 1.27 +typedef void (*pdf_stream_write_callback)(pdf_file_handle pdf_file, 1.28 + struct pdf_obj *stream, 1.29 + void *app_data); 1.30 + 1.31 + 1.32 +void pdf_set_dict_entry (struct pdf_obj *dict_obj, char *key, struct pdf_obj *val); 1.33 +struct pdf_obj *pdf_get_dict_entry (struct pdf_obj *dict_obj, char *key); 1.34 + 1.35 + 1.36 +void pdf_add_array_elem (struct pdf_obj *array_obj, struct pdf_obj *val); 1.37 + 1.38 + 1.39 +/* Create a new object that will NOT be used indirectly */ 1.40 +struct pdf_obj *pdf_new_obj (pdf_obj_type type); 1.41 + 1.42 +struct pdf_obj *pdf_new_bool (int bool); 1.43 + 1.44 +struct pdf_obj *pdf_new_name (char *name); 1.45 + 1.46 +struct pdf_obj *pdf_new_string (char *str); 1.47 + 1.48 +struct pdf_obj *pdf_new_integer (unsigned long val); 1.49 + 1.50 +struct pdf_obj *pdf_new_real (double val); 1.51 + 1.52 + 1.53 +/* Create a new indirect object */ 1.54 +struct pdf_obj *pdf_new_ind_ref (pdf_file_handle pdf_file, struct pdf_obj *obj); 1.55 + 1.56 +/* get the object referenced by an indirect reference */ 1.57 +struct pdf_obj *pdf_deref_ind_obj (struct pdf_obj *ind_obj); 1.58 + 1.59 + 1.60 +unsigned long pdf_get_integer (struct pdf_obj *obj); 1.61 +void pdf_set_integer (struct pdf_obj *obj, unsigned long val); 1.62 + 1.63 + 1.64 +double pdf_get_real (struct pdf_obj *obj); 1.65 +void pdf_set_real (struct pdf_obj *obj, double val); 1.66 + 1.67 + 1.68 +/* The callback will be called when the stream data is to be written to the 1.69 + file. app_data will be passed as an argument to the callback. */ 1.70 +struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file, 1.71 + struct pdf_obj *stream_dict, 1.72 + pdf_stream_write_callback callback, 1.73 + void *app_data); 1.74 + 1.75 +/* The callback should call pdf_stream_write_data to write the actual 1.76 + stream data. */ 1.77 +void pdf_stream_write_data (pdf_file_handle pdf_file, 1.78 + struct pdf_obj *stream, 1.79 + char *data, 1.80 + unsigned long len); 1.81 + 1.82 +void pdf_stream_add_filter (struct pdf_obj *stream, 1.83 + char *filter_name, 1.84 + struct pdf_obj *decode_parms); 1.85 + 1.86 + 1.87 +/* Write the object to the file */ 1.88 +void pdf_write_obj (pdf_file_handle pdf_file, struct pdf_obj *obj); 1.89 + 1.90 + 1.91 +/* Write the indirect object to the file. For most objects this should 1.92 + be done by pdf_write_all_ind_obj() when the file is being closed, but for 1.93 + large objects such as streams, it's probably better to do it as soon as the 1.94 + object is complete. */ 1.95 +void pdf_write_ind_obj (pdf_file_handle pdf_file, struct pdf_obj *ind_obj); 1.96 + 1.97 + 1.98 +/* Write all indirect objects that haven't already been written to the file. */ 1.99 +void pdf_write_all_ind_obj (pdf_file_handle pdf_file); 1.100 + 1.101 + 1.102 +/* Write the cross reference table, and return the maximum object number */ 1.103 +unsigned long pdf_write_xref (pdf_file_handle pdf_file);