specify page mode when file is closed rather than when it is initially created. if USE_OUTLINES but no bookmarks, use USE_NONE instead. REL_0_27

Fri, 14 Mar 2003 08:57:40 +0000

author
eric
date
Fri, 14 Mar 2003 08:57:40 +0000
changeset 133
76c197fe2eeb
parent 132
ccf1c28a2940
child 134
313aba417199

specify page mode when file is closed rather than when it is initially created. if USE_OUTLINES but no bookmarks, use USE_NONE instead.

pdf.c file | annotate | diff | revisions
pdf.h file | annotate | diff | revisions
tumble.c file | annotate | diff | revisions
tumble.h file | annotate | diff | revisions
     1.1 --- a/pdf.c	Fri Mar 14 08:56:38 2003 +0000
     1.2 +++ b/pdf.c	Fri Mar 14 08:57:40 2003 +0000
     1.3 @@ -2,7 +2,7 @@
     1.4   * tumble: build a PDF file from image files
     1.5   *
     1.6   * PDF routines
     1.7 - * $Id: pdf.c,v 1.12 2003/03/14 00:24:37 eric Exp $
     1.8 + * $Id: pdf.c,v 1.13 2003/03/14 00:57:40 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 @@ -67,19 +67,9 @@
    1.13  }
    1.14  
    1.15  
    1.16 -pdf_file_handle pdf_create (char *filename, int page_mode)
    1.17 +pdf_file_handle pdf_create (char *filename)
    1.18  {
    1.19    pdf_file_handle pdf_file;
    1.20 -  char *page_mode_string;
    1.21 -
    1.22 -  switch (page_mode)
    1.23 -    {
    1.24 -    case PDF_PAGE_MODE_USE_NONE:      page_mode_string = "UseNone";     break;
    1.25 -    case PDF_PAGE_MODE_USE_OUTLINES:  page_mode_string = "UseOutlines"; break;
    1.26 -    case PDF_PAGE_MODE_USE_THUMBS:    page_mode_string = "UseThumbs";   break;
    1.27 -    default:
    1.28 -      pdf_fatal ("invalid page mode\n");
    1.29 -    }
    1.30  
    1.31    pdf_file = pdf_calloc (1, sizeof (struct pdf_file));
    1.32  
    1.33 @@ -95,9 +85,6 @@
    1.34    pdf_set_dict_entry (pdf_file->catalog, "Type", pdf_new_name ("Catalog"));
    1.35    pdf_set_dict_entry (pdf_file->catalog, "Pages", pdf_file->root->pages_dict);
    1.36    /* Outlines dictionary will be created later if needed */
    1.37 -  pdf_set_dict_entry (pdf_file->catalog,
    1.38 -		      "PageMode",
    1.39 -		      pdf_new_name (page_mode_string));
    1.40    pdf_set_dict_entry (pdf_file->catalog, "PageLayout", pdf_new_name ("SinglePage"));
    1.41  
    1.42    pdf_file->info    = pdf_new_ind_ref (pdf_file, pdf_new_obj (PT_DICTIONARY));
    1.43 @@ -119,8 +106,31 @@
    1.44  }
    1.45  
    1.46  
    1.47 -void pdf_close (pdf_file_handle pdf_file)
    1.48 +void pdf_close (pdf_file_handle pdf_file, int page_mode)
    1.49  {
    1.50 +  char *page_mode_string;
    1.51 +
    1.52 +  page_mode_string = "UseNone";
    1.53 +
    1.54 +  switch (page_mode)
    1.55 +    {
    1.56 +    case PDF_PAGE_MODE_USE_NONE:
    1.57 +      break;
    1.58 +    case PDF_PAGE_MODE_USE_OUTLINES:
    1.59 +      if (pdf_file->outline_root)
    1.60 +	page_mode_string = "UseOutlines";
    1.61 +      break;
    1.62 +    case PDF_PAGE_MODE_USE_THUMBS:
    1.63 +      page_mode_string = "UseThumbs";
    1.64 +      break;
    1.65 +    default:
    1.66 +      pdf_fatal ("invalid page mode\n");
    1.67 +    }
    1.68 +
    1.69 +  pdf_set_dict_entry (pdf_file->catalog,
    1.70 +		      "PageMode",
    1.71 +		      pdf_new_name (page_mode_string));
    1.72 +
    1.73    /* finalize trees, object numbers aren't allocated until this step */
    1.74    pdf_finalize_name_trees (pdf_file);
    1.75  
     2.1 --- a/pdf.h	Fri Mar 14 08:56:38 2003 +0000
     2.2 +++ b/pdf.h	Fri Mar 14 08:57:40 2003 +0000
     2.3 @@ -2,7 +2,7 @@
     2.4   * tumble: build a PDF file from image files
     2.5   *
     2.6   * PDF routines
     2.7 - * $Id: pdf.h,v 1.10 2003/03/14 00:24:37 eric Exp $
     2.8 + * $Id: pdf.h,v 1.11 2003/03/14 00:57:40 eric Exp $
     2.9   * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
    2.10   *
    2.11   * This program is free software; you can redistribute it and/or modify
    2.12 @@ -30,15 +30,15 @@
    2.13  
    2.14  
    2.15  #define PDF_PAGE_MODE_USE_NONE     0
    2.16 -#define PDF_PAGE_MODE_USE_OUTLINES 1
    2.17 +#define PDF_PAGE_MODE_USE_OUTLINES 1  /* if no outlines, will use NONE */
    2.18  #define PDF_PAGE_MODE_USE_THUMBS   2  /* not yet implemented */
    2.19  
    2.20  
    2.21  void pdf_init (void);
    2.22  
    2.23 -pdf_file_handle pdf_create (char *filename, int page_mode);
    2.24 +pdf_file_handle pdf_create (char *filename);
    2.25  
    2.26 -void pdf_close (pdf_file_handle pdf_file);
    2.27 +void pdf_close (pdf_file_handle pdf_file, int page_mode);
    2.28  
    2.29  void pdf_set_author   (pdf_file_handle pdf_file, char *author);
    2.30  void pdf_set_creator  (pdf_file_handle pdf_file, char *author);
     3.1 --- a/tumble.c	Fri Mar 14 08:56:38 2003 +0000
     3.2 +++ b/tumble.c	Fri Mar 14 08:57:40 2003 +0000
     3.3 @@ -2,7 +2,7 @@
     3.4   * tumble: build a PDF file from image files
     3.5   *
     3.6   * Main program
     3.7 - * $Id: tumble.c,v 1.34 2003/03/14 00:24:37 eric Exp $
     3.8 + * $Id: tumble.c,v 1.35 2003/03/14 00:57:40 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 @@ -159,7 +159,7 @@
    3.13    for (o = output_files; o; o = n)
    3.14      {
    3.15        n = o->next;
    3.16 -      pdf_close (o->pdf);
    3.17 +      pdf_close (o->pdf, PDF_PAGE_MODE_USE_OUTLINES);
    3.18        free (o->name);
    3.19        free (o);
    3.20      }
    3.21 @@ -196,9 +196,7 @@
    3.22        return (0);
    3.23      }
    3.24  
    3.25 -  o->pdf = pdf_create (name, (attributes->has_bookmarks ?
    3.26 -			      PDF_PAGE_MODE_USE_OUTLINES :
    3.27 -			      PDF_PAGE_MODE_USE_NONE));
    3.28 +  o->pdf = pdf_create (name);
    3.29    if (! o->pdf)
    3.30      {
    3.31        fprintf (stderr, "can't open output file '%s'\n", name);
    3.32 @@ -606,8 +604,6 @@
    3.33    memset (& input_attributes, 0, sizeof (input_attributes));
    3.34    memset (& output_attributes, 0, sizeof (output_attributes));
    3.35  
    3.36 -  output_attributes.has_bookmarks = (bookmark_fmt != NULL);
    3.37 -
    3.38    if (! open_pdf_output_file (out_fn, & output_attributes))
    3.39      fatal (3, "error opening output file \"%s\"\n", out_fn);
    3.40    for (i = 0; i < inf_count; i++)
     4.1 --- a/tumble.h	Fri Mar 14 08:56:38 2003 +0000
     4.2 +++ b/tumble.h	Fri Mar 14 08:57:40 2003 +0000
     4.3 @@ -1,7 +1,7 @@
     4.4  /*
     4.5   * tumble: build a PDF file from image files
     4.6   *
     4.7 - * $Id: tumble.h,v 1.14 2003/03/14 00:24:37 eric Exp $
     4.8 + * $Id: tumble.h,v 1.15 2003/03/14 00:57:40 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 @@ -50,7 +50,6 @@
    4.13    char *title;
    4.14    char *subject;
    4.15    char *keywords;
    4.16 -  bool has_bookmarks;
    4.17  } pdf_file_attributes_t;
    4.18  
    4.19  bool open_pdf_output_file (char *name,