pdf.c

changeset 133
76c197fe2eeb
parent 131
4b8c80d77f76
     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