pdf_prim.h

Wed, 12 Mar 2003 10:58:33 +0000

author
eric
date
Wed, 12 Mar 2003 10:58:33 +0000
changeset 108
9b35b78d4c91
parent 101
385a2f77a5d8
child 118
c22e1c0a64fd
permissions
-rw-r--r--

start of JPEG support. changed word_type to word_t.

     1 /*
     2  * t2p: Create a PDF file from the contents of one or more TIFF
     3  *      bilevel image files.  The images in the resulting PDF file
     4  *      will be compressed using ITU-T T.6 (G4) fax encoding.
     5  *
     6  * PDF routines
     7  * $Id: pdf_prim.h,v 1.8 2003/03/11 23:43:56 eric Exp $
     8  * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License version 2 as
    12  * published by the Free Software Foundation.  Note that permission is
    13  * not granted to redistribute this program under the terms of any
    14  * other version of the General Public License.
    15  *
    16  * This program is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
    22  * along with this program; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
    24  */
    27 typedef enum
    28 {
    29   PT_BAD,
    31   /* scalar */
    32   PT_NULL,
    33   PT_BOOL,
    34   PT_NAME,
    35   PT_STRING,
    36   PT_INTEGER,
    37   PT_REAL,
    38   PT_IND_REF,
    40   /* composite */
    41   PT_DICTIONARY,
    42   PT_ARRAY,
    43   PT_STREAM
    44 } pdf_obj_type;
    47 struct pdf_obj;
    50 typedef void (*pdf_stream_write_callback)(pdf_file_handle pdf_file,
    51 					  struct pdf_obj *stream,
    52 					  void *app_data);
    55 void pdf_set_dict_entry (struct pdf_obj *dict_obj, char *key, struct pdf_obj *val);
    56 struct pdf_obj *pdf_get_dict_entry (struct pdf_obj *dict_obj, char *key);
    59 void pdf_add_array_elem (struct pdf_obj *array_obj, struct pdf_obj *val);
    62 /* Create a new object that will NOT be used indirectly */
    63 struct pdf_obj *pdf_new_obj (pdf_obj_type type);
    65 struct pdf_obj *pdf_new_bool (bool val);
    67 struct pdf_obj *pdf_new_name (char *name);
    69 struct pdf_obj *pdf_new_string (char *str);
    71 struct pdf_obj *pdf_new_integer (long val);
    73 struct pdf_obj *pdf_new_real (double val);
    76 /* Create a new indirect object */
    77 struct pdf_obj *pdf_new_ind_ref (pdf_file_handle pdf_file, struct pdf_obj *obj);
    79 /* get the object referenced by an indirect reference */
    80 struct pdf_obj *pdf_deref_ind_obj (struct pdf_obj *ind_obj);
    83 long pdf_get_integer (struct pdf_obj *obj);
    84 void pdf_set_integer (struct pdf_obj *obj, long val);
    87 double pdf_get_real (struct pdf_obj *obj);
    88 void pdf_set_real (struct pdf_obj *obj, double val);
    91 /* returns -1 if o1 < 02, 0 if o1 == o2, 1 if o1 > o2 */
    92 int pdf_compare_obj (struct pdf_obj *o1, struct pdf_obj *o2);
    95 /* The callback will be called when the stream data is to be written to the
    96    file.  app_data will be passed as an argument to the callback. */
    97 struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file,
    98 				struct pdf_obj *stream_dict,
    99 				pdf_stream_write_callback callback,
   100 				void *app_data);
   102 /* The callback should call pdf_stream_write_data() or pdf_stream_printf()
   103    to write the actual stream data. */
   105 void pdf_stream_flush_bits (pdf_file_handle pdf_file,
   106 			    struct pdf_obj *stream);
   108 void pdf_stream_write_data (pdf_file_handle pdf_file,
   109 			    struct pdf_obj *stream,
   110 			    char *data,
   111 			    unsigned long len);
   113 void pdf_stream_printf (pdf_file_handle pdf_file,
   114 			struct pdf_obj *stream,
   115 			char *fmt, ...);
   118 void pdf_stream_add_filter (struct pdf_obj *stream,
   119 			    char *filter_name,
   120 			    struct pdf_obj *decode_parms);
   123 /* Write the object to the file */
   124 void pdf_write_obj (pdf_file_handle pdf_file, struct pdf_obj *obj);
   127 /* Write the indirect object to the file.  For most objects this should
   128    be done by pdf_write_all_ind_obj() when the file is being closed, but for
   129    large objects such as streams, it's probably better to do it as soon as the
   130    object is complete. */
   131 void pdf_write_ind_obj (pdf_file_handle pdf_file, struct pdf_obj *ind_obj);
   134 /* Write all indirect objects that haven't already been written to the file. */
   135 void pdf_write_all_ind_obj (pdf_file_handle pdf_file);
   138 /* Write the cross reference table, and return the maximum object number */
   139 unsigned long pdf_write_xref (pdf_file_handle pdf_file);
   142 /* this isn't really a PDF primitive data type */
   143 char pdf_new_XObject (pdf_page_handle pdf_page, struct pdf_obj *ind_ref);