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().

Thu, 13 Mar 2003 06:56:57 +0000

author
eric
date
Thu, 13 Mar 2003 06:56:57 +0000
changeset 118
c22e1c0a64fd
parent 117
129e16d9b5f4
child 119
cbc382d73a86

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