1 | /* |
2 | * Copyright (C) 2009-2010, Pino Toscano <pino@kde.org> |
3 | * Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> |
4 | * Copyright (C) 2019, Masamichi Hosoda <trueroad@trueroad.jp> |
5 | * Copyright (C) 2019, 2021, 2022, Albert Astals Cid <aacid@kde.org> |
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 as published by |
9 | * the Free Software Foundation; either version 2, or (at your option) |
10 | * any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef POPPLER_DOCUMENT_H |
23 | #define POPPLER_DOCUMENT_H |
24 | |
25 | #include "poppler-global.h" |
26 | #include "poppler-font.h" |
27 | |
28 | #include <map> |
29 | |
30 | namespace poppler { |
31 | |
32 | class destination; |
33 | class document_private; |
34 | class embedded_file; |
35 | class page; |
36 | class toc; |
37 | |
38 | class POPPLER_CPP_EXPORT document : public poppler::noncopyable |
39 | { |
40 | public: |
41 | enum page_mode_enum |
42 | { |
43 | use_none, |
44 | use_outlines, |
45 | use_thumbs, |
46 | fullscreen, |
47 | use_oc, |
48 | use_attach |
49 | }; |
50 | |
51 | enum page_layout_enum |
52 | { |
53 | no_layout, |
54 | single_page, |
55 | one_column, |
56 | two_column_left, |
57 | two_column_right, |
58 | two_page_left, |
59 | two_page_right |
60 | }; |
61 | |
62 | ~document(); |
63 | |
64 | bool is_locked() const; |
65 | bool unlock(const std::string &owner_password, const std::string &user_password); |
66 | |
67 | page_mode_enum page_mode() const; |
68 | page_layout_enum page_layout() const; |
69 | void get_pdf_version(int *major, int *minor) const; |
70 | std::vector<std::string> info_keys() const; |
71 | |
72 | ustring info_key(const std::string &key) const; |
73 | bool set_info_key(const std::string &key, const ustring &val); |
74 | |
75 | [[deprecated]] time_type info_date(const std::string &key) const; |
76 | [[deprecated]] bool set_info_date(const std::string &key, time_type val); |
77 | time_t info_date_t(const std::string &key) const; |
78 | bool set_info_date_t(const std::string &key, time_t val); |
79 | |
80 | ustring get_title() const; |
81 | bool set_title(const ustring &title); |
82 | ustring get_author() const; |
83 | bool set_author(const ustring &author); |
84 | ustring get_subject() const; |
85 | bool set_subject(const ustring &subject); |
86 | ustring get_keywords() const; |
87 | bool set_keywords(const ustring &keywords); |
88 | ustring get_creator() const; |
89 | bool set_creator(const ustring &creator); |
90 | ustring get_producer() const; |
91 | bool set_producer(const ustring &producer); |
92 | [[deprecated]] time_type get_creation_date() const; |
93 | [[deprecated]] bool set_creation_date(time_type creation_date); |
94 | time_t get_creation_date_t() const; |
95 | bool set_creation_date_t(time_t creation_date); |
96 | [[deprecated]] time_type get_modification_date() const; |
97 | [[deprecated]] bool set_modification_date(time_type mod_date); |
98 | time_t get_modification_date_t() const; |
99 | bool set_modification_date_t(time_t mod_date); |
100 | |
101 | bool remove_info(); |
102 | |
103 | bool is_encrypted() const; |
104 | bool is_linearized() const; |
105 | bool has_permission(permission_enum which) const; |
106 | ustring metadata() const; |
107 | bool get_pdf_id(std::string *permanent_id, std::string *update_id) const; |
108 | |
109 | int pages() const; |
110 | page *create_page(const ustring &label) const; |
111 | page *create_page(int index) const; |
112 | |
113 | std::vector<font_info> fonts() const; |
114 | font_iterator *create_font_iterator(int start_page = 0) const; |
115 | |
116 | toc *create_toc() const; |
117 | |
118 | bool has_embedded_files() const; |
119 | std::vector<embedded_file *> embedded_files() const; |
120 | |
121 | // Named destinations are bytestrings, not string. |
122 | // So we use std::string instead of ustring. |
123 | std::map<std::string, destination> create_destination_map() const; |
124 | |
125 | bool save(const std::string &file_name) const; |
126 | bool save_a_copy(const std::string &file_name) const; |
127 | |
128 | static document *load_from_file(const std::string &file_name, const std::string &owner_password = std::string(), const std::string &user_password = std::string()); |
129 | static document *load_from_data(byte_array *file_data, const std::string &owner_password = std::string(), const std::string &user_password = std::string()); |
130 | static document *load_from_raw_data(const char *file_data, int file_data_length, const std::string &owner_password = std::string(), const std::string &user_password = std::string()); |
131 | |
132 | private: |
133 | explicit document(document_private &dd); |
134 | |
135 | document_private *d; |
136 | friend class document_private; |
137 | }; |
138 | |
139 | } |
140 | |
141 | #endif |
142 | |