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