| 1 |
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. |
| 2 |
|
| 3 |
Copyright (C) 2002-2021 by Jin-Hwan Cho and Shunsaku Hirata, |
| 4 |
the dvipdfmx project team. |
| 5 |
|
| 6 |
Copyright (C) 1998, 1999 by Mark A. Wicks <[email protected]> |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 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-1307 USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef _PDFDOC_H_ |
| 24 |
#define _PDFDOC_H_ |
| 25 |
|
| 26 |
#include "pdfobj.h" |
| 27 |
#include "pdfdev.h" |
| 28 |
|
| 29 |
enum pdf_page_boundary |
| 30 |
{ |
| 31 |
pdf_page_boundary__auto = 0, |
| 32 |
pdf_page_boundary_mediabox, |
| 33 |
pdf_page_boundary_cropbox, |
| 34 |
pdf_page_boundary_artbox, |
| 35 |
pdf_page_boundary_trimbox, |
| 36 |
pdf_page_boundary_bleedbox |
| 37 |
}; |
| 38 |
|
| 39 |
#define PDF_DOC_GRABBING_NEST_MAX 4 |
| 40 |
|
| 41 |
struct pdf_dev_setting { |
| 42 |
double dvi2pts; /* conversion unit */ |
| 43 |
int precision; /* number of decimal digits kept */ |
| 44 |
int ignore_colors; /* 1 for black or white */ |
| 45 |
}; |
| 46 |
|
| 47 |
struct pdf_enc_setting { |
| 48 |
int key_size; |
| 49 |
uint32_t permission; |
| 50 |
const char *uplain, *oplain; /* password */ |
| 51 |
int use_aes; |
| 52 |
int encrypt_metadata; |
| 53 |
}; |
| 54 |
|
| 55 |
struct pdf_obj_setting { |
| 56 |
int enable_objstm; |
| 57 |
int enable_predictor; |
| 58 |
int compression_level; |
| 59 |
}; |
| 60 |
|
| 61 |
struct pdf_setting |
| 62 |
{ |
| 63 |
int ver_major, ver_minor; |
| 64 |
double media_width, media_height; |
| 65 |
struct { |
| 66 |
double x, y; |
| 67 |
} annot_grow_amount; |
| 68 |
int outline_open_depth; |
| 69 |
int check_gotos; |
| 70 |
int enable_manual_thumb; |
| 71 |
int enable_encrypt; |
| 72 |
struct pdf_enc_setting encrypt; |
| 73 |
struct pdf_dev_setting device; |
| 74 |
struct pdf_obj_setting object; |
| 75 |
}; |
| 76 |
|
| 77 |
extern void pdf_open_document (const char *filename, |
| 78 |
const char *creator, |
| 79 |
const unsigned char *id1, |
| 80 |
const unsigned char *id2, |
| 81 |
struct pdf_setting settings); |
| 82 |
extern void pdf_close_document(void); |
| 83 |
|
| 84 |
/* They just return PDF dictionary object. |
| 85 |
* Callers are completely responsible for doing right thing... |
| 86 |
*/ |
| 87 |
extern pdf_obj *pdf_doc_get_dictionary(const char *category); |
| 88 |
extern pdf_obj *pdf_doc_get_reference(const char *category); |
| 89 |
|
| 90 |
#define pdf_doc_page_tree() pdf_doc_get_dictionary("Pages") |
| 91 |
#define pdf_doc_catalog() pdf_doc_get_dictionary("Catalog") |
| 92 |
#define pdf_doc_docinfo() pdf_doc_get_dictionary("Info") |
| 93 |
#define pdf_doc_names() pdf_doc_get_dictionary("Names") |
| 94 |
#define pdf_doc_this_page() pdf_doc_get_dictionary("@THISPAGE") |
| 95 |
|
| 96 |
extern int pdf_doc_get_page_count(pdf_file *pf); |
| 97 |
extern pdf_obj *pdf_doc_get_page(pdf_file *pf, int page_no, char * page_name, |
| 98 |
enum pdf_page_boundary opt_bbox, |
| 99 |
pdf_rect *bbox, pdf_tmatrix *matrix, pdf_obj **resources_p); |
| 100 |
|
| 101 |
extern int pdf_doc_current_page_number(void); |
| 102 |
extern pdf_obj *pdf_doc_current_page_resources(void); |
| 103 |
|
| 104 |
extern pdf_obj *pdf_doc_ref_page(unsigned page_no); |
| 105 |
#define pdf_doc_this_page_ref() pdf_doc_get_reference("@THISPAGE") |
| 106 |
#define pdf_doc_next_page_ref() pdf_doc_get_reference("@NEXTPAGE") |
| 107 |
#define pdf_doc_prev_page_ref() pdf_doc_get_reference("@PREVPAGE") |
| 108 |
|
| 109 |
/* Not really managing tree... |
| 110 |
* There should be something for number tree. |
| 111 |
*/ |
| 112 |
extern int pdf_doc_add_names(const char *category, |
| 113 |
const void *key, int keylen, pdf_obj *value); |
| 114 |
|
| 115 |
extern void pdf_doc_set_bop_content(const char *str, unsigned length); |
| 116 |
extern void pdf_doc_set_eop_content(const char *str, unsigned length); |
| 117 |
|
| 118 |
/* Page */ |
| 119 |
extern void pdf_doc_begin_page(double scale, double x_origin, double y_origin); |
| 120 |
extern void pdf_doc_end_page(void); |
| 121 |
|
| 122 |
extern void pdf_doc_set_mediabox(unsigned page_no, const pdf_rect *mediabox); |
| 123 |
|
| 124 |
extern void pdf_doc_add_page_content(const char *buffer, unsigned length); |
| 125 |
extern void pdf_doc_add_page_resource(const char *category, |
| 126 |
const char *resource_name, pdf_obj *resources); |
| 127 |
|
| 128 |
/* Article thread */ |
| 129 |
extern void pdf_doc_begin_article(const char *article_id, pdf_obj *info); |
| 130 |
extern void pdf_doc_add_bead(const char *article_id, |
| 131 |
const char *bead_id, |
| 132 |
int page_no, const pdf_rect *rect); |
| 133 |
|
| 134 |
/* Bookmarks */ |
| 135 |
extern int pdf_doc_bookmarks_up(void); |
| 136 |
extern int pdf_doc_bookmarks_down(void); |
| 137 |
extern void pdf_doc_bookmarks_add(pdf_obj *dict, int is_open); |
| 138 |
extern int pdf_doc_bookmarks_depth(void); |
| 139 |
|
| 140 |
/* Returns xobj_id of started xform. */ |
| 141 |
extern int pdf_doc_begin_grabbing(const char *ident, |
| 142 |
double ref_x, double ref_y, |
| 143 |
const pdf_rect *cropbox); |
| 144 |
extern void pdf_doc_end_grabbing(pdf_obj *attrib); |
| 145 |
|
| 146 |
/* Annotation */ |
| 147 |
extern void pdf_doc_add_annot(unsigned page_no, |
| 148 |
const pdf_rect *rect, |
| 149 |
pdf_obj *annot_dict, |
| 150 |
int new_annot); |
| 151 |
|
| 152 |
/* Annotation with auto- clip and line (or page) break */ |
| 153 |
extern void pdf_doc_begin_annot(pdf_obj *dict); |
| 154 |
extern void pdf_doc_end_annot(void); |
| 155 |
|
| 156 |
extern void pdf_doc_break_annot(void); |
| 157 |
extern void pdf_doc_expand_box(const pdf_rect *rect); |
| 158 |
|
| 159 |
/* Manual thumbnail */ |
| 160 |
extern void pdf_doc_enable_manual_thumbnails(void); |
| 161 |
|
| 162 |
#if 0 |
| 163 |
/* PageLabels - */ |
| 164 |
extern void pdf_doc_set_pagelabel (int page_start, |
| 165 |
const char *type, |
| 166 |
const void *prefix, int pfrx_len, |
| 167 |
int counter_start); |
| 168 |
#endif |
| 169 |
|
| 170 |
/* Similar to bop_content */ |
| 171 |
#include "pdfcolor.h" |
| 172 |
extern void pdf_doc_set_bgcolor(const pdf_color *color); |
| 173 |
|
| 174 |
/* Sorry no appropriate place to put this... */ |
| 175 |
extern struct ht_table *global_names; |
| 176 |
|
| 177 |
#endif /* _PDFDOC_H_ */ |