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