Poppler CPP 25.04.90
poppler-document.h
Go to the documentation of this file.
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 * Copyright (C) 2025 Nathanael d. Noblet <nathanael@noblet.ca>
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, or (at your option)
11 * 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef POPPLER_DOCUMENT_H
24#define POPPLER_DOCUMENT_H
25
26#include "poppler-global.h"
27#include "poppler-font.h"
28
29#include <map>
30
31namespace poppler {
32
33class destination;
34class document_private;
35class embedded_file;
36class page;
37class toc;
38
39class POPPLER_CPP_EXPORT document : public poppler::noncopyable
40{
41public:
51
52 enum page_layout_enum
53 {
54 no_layout,
55 single_page,
56 one_column,
57 two_column_left,
58 two_column_right,
59 two_page_left,
60 two_page_right
61 };
62
63 enum class form_type
64 {
65 none,
66 acro,
67 xfa
68 };
69
70 ~document();
71
72 bool is_locked() const;
73 bool unlock(const std::string &owner_password, const std::string &user_password);
74
75 page_mode_enum page_mode() const;
76 page_layout_enum page_layout() const;
77 void get_pdf_version(int *major, int *minor) const;
78 std::vector<std::string> info_keys() const;
79
80 ustring info_key(const std::string &key) const;
81 bool set_info_key(const std::string &key, const ustring &val);
82
83 [[deprecated]] time_type info_date(const std::string &key) const;
84 [[deprecated]] bool set_info_date(const std::string &key, time_type val);
85 time_t info_date_t(const std::string &key) const;
86 bool set_info_date_t(const std::string &key, time_t val);
87
88 ustring get_title() const;
89 bool set_title(const ustring &title);
90 ustring get_author() const;
91 bool set_author(const ustring &author);
92 ustring get_subject() const;
93 bool set_subject(const ustring &subject);
94 ustring get_keywords() const;
95 bool set_keywords(const ustring &keywords);
96 ustring get_creator() const;
97 bool set_creator(const ustring &creator);
98 ustring get_producer() const;
99 bool set_producer(const ustring &producer);
100 [[deprecated]] time_type get_creation_date() const;
101 [[deprecated]] bool set_creation_date(time_type creation_date);
102 time_t get_creation_date_t() const;
103 bool set_creation_date_t(time_t creation_date);
104 [[deprecated]] time_type get_modification_date() const;
105 [[deprecated]] bool set_modification_date(time_type mod_date);
106 time_t get_modification_date_t() const;
107 bool set_modification_date_t(time_t mod_date);
108
109 bool remove_info();
110
111 bool is_encrypted() const;
112 bool is_linearized() const;
113 form_type form_type() const;
114 bool has_javascript() const;
115
116 bool has_permission(permission_enum which) const;
117 ustring metadata() const;
118 bool get_pdf_id(std::string *permanent_id, std::string *update_id) const;
119
120 int pages() const;
121 page *create_page(const ustring &label) const;
122 page *create_page(int index) const;
123
124 std::vector<font_info> fonts() const;
125 font_iterator *create_font_iterator(int start_page = 0) const;
126
127 toc *create_toc() const;
128
129 bool has_embedded_files() const;
130 std::vector<embedded_file *> embedded_files() const;
131
132 // Named destinations are bytestrings, not string.
133 // So we use std::string instead of ustring.
134 std::map<std::string, destination> create_destination_map() const;
135
136 bool save(const std::string &file_name) const;
137 bool save_a_copy(const std::string &file_name) const;
138
139 static document *load_from_file(const std::string &file_name, const std::string &owner_password = std::string(), const std::string &user_password = std::string());
140 static document *load_from_data(byte_array *file_data, const std::string &owner_password = std::string(), const std::string &user_password = std::string());
141 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());
142
143private:
144 explicit document(document_private &dd);
145
146 document_private *d;
147 friend class document_private;
148};
149
150}
151
152#endif
Represents a PDF document.
Definition poppler-document.h:40
page_mode_enum
The various page modes available in a PDF document.
Definition poppler-document.h:43
@ use_thumbs
The document specifies that should be open a view of the thumbnails of its pages.
Definition poppler-document.h:46
@ use_outlines
The document specifies its TOC (table of contents) should be open.
Definition poppler-document.h:45
@ use_none
The document specifies no particular page mode.
Definition poppler-document.h:44
@ use_oc
The document specifies that should be open a view of its Optional Content (also known as layers).
Definition poppler-document.h:48
@ fullscreen
The document specifies it wants to be open in a fullscreen mode.
Definition poppler-document.h:47
Single namespace containing all the classes and functions of poppler-cpp.
Definition poppler-destination.h:27