Thu, 13 Mar 2003 06:56:57 +0000
updated pdf_write_g4_fax_image() to add ImageB to page ProcSet array. Added pdf_add_array_elem_unique() function. Added support for name objects to pdf_compare_obj().
pdf.c | file | annotate | diff | revisions | |
pdf_g4.c | file | annotate | diff | revisions | |
pdf_prim.c | file | annotate | diff | revisions | |
pdf_prim.h | file | annotate | diff | revisions |
1.1 diff -r 129e16d9b5f4 -r c22e1c0a64fd pdf.c 1.2 --- a/pdf.c Thu Mar 13 03:39:38 2003 +0000 1.3 +++ b/pdf.c Thu Mar 13 06:56:57 2003 +0000 1.4 @@ -4,7 +4,7 @@ 1.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 1.6 * 1.7 * PDF routines 1.8 - * $Id: pdf.c,v 1.7 2003/03/12 03:17:00 eric Exp $ 1.9 + * $Id: pdf.c,v 1.8 2003/03/12 22:56:57 eric Exp $ 1.10 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.11 * 1.12 * This program is free software; you can redistribute it and/or modify 1.13 @@ -181,7 +181,7 @@ 1.14 pdf_add_array_elem (page->media_box, pdf_new_real (height)); 1.15 1.16 page->procset = pdf_new_obj (PT_ARRAY); 1.17 - pdf_add_array_elem (page->procset, pdf_new_name ("PDF")); 1.18 + pdf_add_array_elem_unique (page->procset, pdf_new_name ("PDF")); 1.19 1.20 page->resources = pdf_new_obj (PT_DICTIONARY); 1.21 pdf_set_dict_entry (page->resources, "ProcSet", page->procset);
2.1 diff -r 129e16d9b5f4 -r c22e1c0a64fd pdf_g4.c 2.2 --- a/pdf_g4.c Thu Mar 13 03:39:38 2003 +0000 2.3 +++ b/pdf_g4.c Thu Mar 13 06:56:57 2003 +0000 2.4 @@ -4,7 +4,7 @@ 2.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 2.6 * 2.7 * PDF routines 2.8 - * $Id: pdf_g4.c,v 1.12 2003/03/11 23:53:55 eric Exp $ 2.9 + * $Id: pdf_g4.c,v 1.13 2003/03/12 22:56:57 eric Exp $ 2.10 * Copyright 2003 Eric Smith <eric@brouhaha.com> 2.11 * 2.12 * This program is free software; you can redistribute it and/or modify 2.13 @@ -101,6 +101,8 @@ 2.14 2.15 struct pdf_obj *content_stream; 2.16 2.17 + pdf_add_array_elem_unique (pdf_page->procset, pdf_new_name ("ImageB")); 2.18 + 2.19 image = pdf_calloc (1, sizeof (struct pdf_g4_image)); 2.20 2.21 image->width = width;
3.1 diff -r 129e16d9b5f4 -r c22e1c0a64fd pdf_prim.c 3.2 --- a/pdf_prim.c Thu Mar 13 03:39:38 2003 +0000 3.3 +++ b/pdf_prim.c Thu Mar 13 06:56:57 2003 +0000 3.4 @@ -4,7 +4,7 @@ 3.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 3.6 * 3.7 * PDF routines 3.8 - * $Id: pdf_prim.c,v 1.9 2003/03/11 23:43:56 eric Exp $ 3.9 + * $Id: pdf_prim.c,v 1.10 2003/03/12 22:56:57 eric Exp $ 3.10 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 3.11 * 3.12 * This program is free software; you can redistribute it and/or modify 3.13 @@ -192,6 +192,32 @@ 3.14 } 3.15 3.16 3.17 +void pdf_add_array_elem_unique (struct pdf_obj *array_obj, struct pdf_obj *val) 3.18 +{ 3.19 + struct pdf_array_elem *elem; 3.20 + 3.21 + if (array_obj->type == PT_IND_REF) 3.22 + array_obj = pdf_deref_ind_obj (array_obj); 3.23 + 3.24 + pdf_assert (array_obj->type == PT_ARRAY); 3.25 + 3.26 + for (elem = array_obj->val.array.first; elem; elem = elem->next) 3.27 + if (pdf_compare_obj (val, elem->val) == 0) 3.28 + return; 3.29 + 3.30 + elem = pdf_calloc (1, sizeof (struct pdf_array_elem)); 3.31 + 3.32 + elem->val = ref (val); 3.33 + 3.34 + if (! array_obj->val.array.first) 3.35 + array_obj->val.array.first = elem; 3.36 + else 3.37 + array_obj->val.array.last->next = elem; 3.38 + 3.39 + array_obj->val.array.last = elem; 3.40 +} 3.41 + 3.42 + 3.43 struct pdf_obj *pdf_new_obj (pdf_obj_type type) 3.44 { 3.45 struct pdf_obj *obj = pdf_calloc (1, sizeof (struct pdf_obj)); 3.46 @@ -374,6 +400,8 @@ 3.47 return (0); 3.48 case PT_STRING: 3.49 return (strcmp (o1->val.string, o2->val.string)); 3.50 + case PT_NAME: 3.51 + return (strcmp (o1->val.name, o2->val.name)); 3.52 default: 3.53 pdf_fatal ("invalid object type for comparison\n"); 3.54 }
4.1 diff -r 129e16d9b5f4 -r c22e1c0a64fd pdf_prim.h 4.2 --- a/pdf_prim.h Thu Mar 13 03:39:38 2003 +0000 4.3 +++ b/pdf_prim.h Thu Mar 13 06:56:57 2003 +0000 4.4 @@ -4,7 +4,7 @@ 4.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 4.6 * 4.7 * PDF routines 4.8 - * $Id: pdf_prim.h,v 1.8 2003/03/11 23:43:56 eric Exp $ 4.9 + * $Id: pdf_prim.h,v 1.9 2003/03/12 22:56:57 eric Exp $ 4.10 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 4.11 * 4.12 * This program is free software; you can redistribute it and/or modify 4.13 @@ -52,6 +52,11 @@ 4.14 void *app_data); 4.15 4.16 4.17 +/* returns -1 if o1 < 02, 0 if o1 == o2, 1 if o1 > o2 */ 4.18 +/* only works for integer, real, string, and name objects */ 4.19 +int pdf_compare_obj (struct pdf_obj *o1, struct pdf_obj *o2); 4.20 + 4.21 + 4.22 void pdf_set_dict_entry (struct pdf_obj *dict_obj, char *key, struct pdf_obj *val); 4.23 struct pdf_obj *pdf_get_dict_entry (struct pdf_obj *dict_obj, char *key); 4.24 4.25 @@ -59,6 +64,14 @@ 4.26 void pdf_add_array_elem (struct pdf_obj *array_obj, struct pdf_obj *val); 4.27 4.28 4.29 +/* Following is intended for things like ProcSet in which an array object 4.30 + is used to represent a set. Only works if all objects in array, and 4.31 + the element to be added are of scalar types (types that are supported 4.32 + by pdf_compare_obj. Not efficient for large arrays as it does a 4.33 + comaprison to every element. */ 4.34 +void pdf_add_array_elem_unique (struct pdf_obj *array_obj, struct pdf_obj *val); 4.35 + 4.36 + 4.37 /* Create a new object that will NOT be used indirectly */ 4.38 struct pdf_obj *pdf_new_obj (pdf_obj_type type); 4.39 4.40 @@ -88,10 +101,6 @@ 4.41 void pdf_set_real (struct pdf_obj *obj, double val); 4.42 4.43 4.44 -/* returns -1 if o1 < 02, 0 if o1 == o2, 1 if o1 > o2 */ 4.45 -int pdf_compare_obj (struct pdf_obj *o1, struct pdf_obj *o2); 4.46 - 4.47 - 4.48 /* The callback will be called when the stream data is to be written to the 4.49 file. app_data will be passed as an argument to the callback. */ 4.50 struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file,