1 /*
2 * tumble: build a PDF file from image files
3 *
4 * PDF routines
5 * Copyright 2003, 2017 Eric Smith <spacewar@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. Note that permission is
10 * not granted to redistribute this program under the terms of any
11 * other version of the General Public License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
21 *
22 * 2007-05-07 [JDB] Fixed a bug wherein a page label specifying prefix without
23 * a style (e.g., LABEL <prefix>) produced bad PDF (no labels
24 * were displayed). Should have output "/P <prefix>" but
25 * instead output "/S /P <prefix>".
26 */
27
28
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34
35
36 #include "bitblt.h"
37 #include "pdf.h"
38 #include "pdf_util.h"
39 #include "pdf_prim.h"
40 #include "pdf_private.h"
41 #include "pdf_name_tree.h"
42
43
pdf_new_page_label(pdf_file_handle pdf_file,int page_index,int base,int count,char style,char * prefix)44 void pdf_new_page_label (pdf_file_handle pdf_file,
45 int page_index,
46 int base,
47 int count,
48 char style,
49 char *prefix)
50 {
51 struct pdf_obj *label_dict;
52 char style_str [2] = { style, '\0' };
53
54 if (! pdf_file->page_label_tree)
55 {
56 pdf_file->page_label_tree = pdf_new_name_tree (pdf_file, 1);
57 }
58
59 label_dict = pdf_new_obj (PT_DICTIONARY);
60
61 if (style)
62 pdf_set_dict_entry (label_dict, "S", pdf_new_name (style_str));
63
64 if (prefix)
65 pdf_set_dict_entry (label_dict, "P", pdf_new_string (prefix));
66
67 if (base > 1)
68 pdf_set_dict_entry (label_dict, "St", pdf_new_integer (base));
69
70 pdf_add_number_tree_element (pdf_file->page_label_tree,
71 page_index,
72 label_dict);
73 }
74
75