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.

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