specify page mode when file is closed rather than when it is initially created. if USE_OUTLINES but no bookmarks, use USE_NONE instead.
This commit is contained in:
42
pdf.c
42
pdf.c
@@ -2,7 +2,7 @@
|
||||
* tumble: build a PDF file from image files
|
||||
*
|
||||
* PDF routines
|
||||
* $Id: pdf.c,v 1.12 2003/03/14 00:24:37 eric Exp $
|
||||
* $Id: pdf.c,v 1.13 2003/03/14 00:57:40 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -67,19 +67,9 @@ struct pdf_pages *pdf_new_pages (pdf_file_handle pdf_file)
|
||||
}
|
||||
|
||||
|
||||
pdf_file_handle pdf_create (char *filename, int page_mode)
|
||||
pdf_file_handle pdf_create (char *filename)
|
||||
{
|
||||
pdf_file_handle pdf_file;
|
||||
char *page_mode_string;
|
||||
|
||||
switch (page_mode)
|
||||
{
|
||||
case PDF_PAGE_MODE_USE_NONE: page_mode_string = "UseNone"; break;
|
||||
case PDF_PAGE_MODE_USE_OUTLINES: page_mode_string = "UseOutlines"; break;
|
||||
case PDF_PAGE_MODE_USE_THUMBS: page_mode_string = "UseThumbs"; break;
|
||||
default:
|
||||
pdf_fatal ("invalid page mode\n");
|
||||
}
|
||||
|
||||
pdf_file = pdf_calloc (1, sizeof (struct pdf_file));
|
||||
|
||||
@@ -95,9 +85,6 @@ pdf_file_handle pdf_create (char *filename, int page_mode)
|
||||
pdf_set_dict_entry (pdf_file->catalog, "Type", pdf_new_name ("Catalog"));
|
||||
pdf_set_dict_entry (pdf_file->catalog, "Pages", pdf_file->root->pages_dict);
|
||||
/* Outlines dictionary will be created later if needed */
|
||||
pdf_set_dict_entry (pdf_file->catalog,
|
||||
"PageMode",
|
||||
pdf_new_name (page_mode_string));
|
||||
pdf_set_dict_entry (pdf_file->catalog, "PageLayout", pdf_new_name ("SinglePage"));
|
||||
|
||||
pdf_file->info = pdf_new_ind_ref (pdf_file, pdf_new_obj (PT_DICTIONARY));
|
||||
@@ -119,8 +106,31 @@ pdf_file_handle pdf_create (char *filename, int page_mode)
|
||||
}
|
||||
|
||||
|
||||
void pdf_close (pdf_file_handle pdf_file)
|
||||
void pdf_close (pdf_file_handle pdf_file, int page_mode)
|
||||
{
|
||||
char *page_mode_string;
|
||||
|
||||
page_mode_string = "UseNone";
|
||||
|
||||
switch (page_mode)
|
||||
{
|
||||
case PDF_PAGE_MODE_USE_NONE:
|
||||
break;
|
||||
case PDF_PAGE_MODE_USE_OUTLINES:
|
||||
if (pdf_file->outline_root)
|
||||
page_mode_string = "UseOutlines";
|
||||
break;
|
||||
case PDF_PAGE_MODE_USE_THUMBS:
|
||||
page_mode_string = "UseThumbs";
|
||||
break;
|
||||
default:
|
||||
pdf_fatal ("invalid page mode\n");
|
||||
}
|
||||
|
||||
pdf_set_dict_entry (pdf_file->catalog,
|
||||
"PageMode",
|
||||
pdf_new_name (page_mode_string));
|
||||
|
||||
/* finalize trees, object numbers aren't allocated until this step */
|
||||
pdf_finalize_name_trees (pdf_file);
|
||||
|
||||
|
||||
8
pdf.h
8
pdf.h
@@ -2,7 +2,7 @@
|
||||
* tumble: build a PDF file from image files
|
||||
*
|
||||
* PDF routines
|
||||
* $Id: pdf.h,v 1.10 2003/03/14 00:24:37 eric Exp $
|
||||
* $Id: pdf.h,v 1.11 2003/03/14 00:57:40 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -30,15 +30,15 @@ typedef struct pdf_bookmark *pdf_bookmark_handle;
|
||||
|
||||
|
||||
#define PDF_PAGE_MODE_USE_NONE 0
|
||||
#define PDF_PAGE_MODE_USE_OUTLINES 1
|
||||
#define PDF_PAGE_MODE_USE_OUTLINES 1 /* if no outlines, will use NONE */
|
||||
#define PDF_PAGE_MODE_USE_THUMBS 2 /* not yet implemented */
|
||||
|
||||
|
||||
void pdf_init (void);
|
||||
|
||||
pdf_file_handle pdf_create (char *filename, int page_mode);
|
||||
pdf_file_handle pdf_create (char *filename);
|
||||
|
||||
void pdf_close (pdf_file_handle pdf_file);
|
||||
void pdf_close (pdf_file_handle pdf_file, int page_mode);
|
||||
|
||||
void pdf_set_author (pdf_file_handle pdf_file, char *author);
|
||||
void pdf_set_creator (pdf_file_handle pdf_file, char *author);
|
||||
|
||||
10
tumble.c
10
tumble.c
@@ -2,7 +2,7 @@
|
||||
* tumble: build a PDF file from image files
|
||||
*
|
||||
* Main program
|
||||
* $Id: tumble.c,v 1.34 2003/03/14 00:24:37 eric Exp $
|
||||
* $Id: tumble.c,v 1.35 2003/03/14 00:57:40 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -159,7 +159,7 @@ bool close_pdf_output_files (void)
|
||||
for (o = output_files; o; o = n)
|
||||
{
|
||||
n = o->next;
|
||||
pdf_close (o->pdf);
|
||||
pdf_close (o->pdf, PDF_PAGE_MODE_USE_OUTLINES);
|
||||
free (o->name);
|
||||
free (o);
|
||||
}
|
||||
@@ -196,9 +196,7 @@ bool open_pdf_output_file (char *name,
|
||||
return (0);
|
||||
}
|
||||
|
||||
o->pdf = pdf_create (name, (attributes->has_bookmarks ?
|
||||
PDF_PAGE_MODE_USE_OUTLINES :
|
||||
PDF_PAGE_MODE_USE_NONE));
|
||||
o->pdf = pdf_create (name);
|
||||
if (! o->pdf)
|
||||
{
|
||||
fprintf (stderr, "can't open output file '%s'\n", name);
|
||||
@@ -606,8 +604,6 @@ void main_args (char *out_fn,
|
||||
memset (& input_attributes, 0, sizeof (input_attributes));
|
||||
memset (& output_attributes, 0, sizeof (output_attributes));
|
||||
|
||||
output_attributes.has_bookmarks = (bookmark_fmt != NULL);
|
||||
|
||||
if (! open_pdf_output_file (out_fn, & output_attributes))
|
||||
fatal (3, "error opening output file \"%s\"\n", out_fn);
|
||||
for (i = 0; i < inf_count; i++)
|
||||
|
||||
3
tumble.h
3
tumble.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* tumble: build a PDF file from image files
|
||||
*
|
||||
* $Id: tumble.h,v 1.14 2003/03/14 00:24:37 eric Exp $
|
||||
* $Id: tumble.h,v 1.15 2003/03/14 00:57:40 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -50,7 +50,6 @@ typedef struct
|
||||
char *title;
|
||||
char *subject;
|
||||
char *keywords;
|
||||
bool has_bookmarks;
|
||||
} pdf_file_attributes_t;
|
||||
|
||||
bool open_pdf_output_file (char *name,
|
||||
|
||||
Reference in New Issue
Block a user