-
Notifications
You must be signed in to change notification settings - Fork 7
/
pdf.h
143 lines (109 loc) · 4.12 KB
/
pdf.h
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* tumble: build a PDF file from image files
*
* PDF routines
* Copyright 2001, 2002, 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-06-28 [JDB] Increase page limits from 45" to 200" square.
* 2010-09-02 [JDB] Added support for min-is-black TIFF images.
* 2014-02-18 [JDB] Added PDF_PRODUCER definition.
*/
#ifndef PDF_H
#define PDF_H
#include "semantics.h"
/* Acrobat default units aren't really points, but they're close. */
#define POINTS_PER_INCH 72.0
/* Page size for Acrobat Reader 4.0 and later is 200 x 200 inches.
Old limit of 45 inches applied to Acrobat Reader 3.x only. */
#define PAGE_MAX_INCHES 200
#define PAGE_MAX_POINTS (PAGE_MAX_INCHES * POINTS_PER_INCH)
typedef struct pdf_file *pdf_file_handle;
typedef struct pdf_page *pdf_page_handle;
typedef struct pdf_bookmark *pdf_bookmark_handle;
#define PDF_PAGE_MODE_USE_NONE 0
#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);
void pdf_close (pdf_file_handle pdf_file, int page_mode);
#define AS_STR(S) #S
#define TO_STR(S) AS_STR(S)
#define PDF_PRODUCER "tumble " TO_STR(TUMBLE_VERSION) \
" by Eric Smith (modified by J. David Bryan)"
void pdf_set_author (pdf_file_handle pdf_file, char *author);
void pdf_set_creator (pdf_file_handle pdf_file, char *creator);
void pdf_set_producer (pdf_file_handle pdf_file, char *producer);
void pdf_set_title (pdf_file_handle pdf_file, char *title);
void pdf_set_subject (pdf_file_handle pdf_file, char *subject);
void pdf_set_keywords (pdf_file_handle pdf_file, char *keywords);
/* width and height in units of 1/72 inch */
pdf_page_handle pdf_new_page (pdf_file_handle pdf_file,
double width,
double height);
void pdf_close_page (pdf_page_handle pdf_page);
void pdf_write_text (pdf_page_handle pdf_page);
/* The length of the data must be Rows * rowbytes.
Note that rowbytes must be at least (Columns+7)/8, but may be arbitrarily
large. */
void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double x,
double y,
double width,
double height,
bool negative,
Bitmap *bitmap,
overlay_t *overlay,
colormap_t *colormap,
rgb_range_t *transparency);
void pdf_write_jpeg_image (pdf_page_handle pdf_page,
double x,
double y,
double width,
double height,
bool color,
uint32_t width_samples,
uint32_t height_samples,
rgb_range_t *transparency,
FILE *f);
void pdf_write_png_image (pdf_page_handle pdf_page,
double x,
double y,
double width,
double height,
int color,
char *pal,
int palent,
int bpp,
uint32_t width_samples,
uint32_t height_samples,
rgb_range_t *transparency,
FILE *f);
void pdf_set_page_number (pdf_page_handle pdf_page, char *page_number);
/* Create a new bookmark, under the specified parent, or at the top
level if parent is NULL. */
pdf_bookmark_handle pdf_new_bookmark (pdf_bookmark_handle parent,
char *title,
bool open,
pdf_page_handle pdf_page);
void pdf_new_page_label (pdf_file_handle pdf_file,
int page_index,
int base,
int count,
char style,
char *prefix);
#endif // PDF_H