| 1 |
/* poppler-qt.h: qt interface to poppler |
| 2 |
* Copyright (C) 2005, Net Integration Technologies, Inc. |
| 3 |
* Copyright (C) 2005, 2007, Brad Hards <[email protected]> |
| 4 |
* Copyright (C) 2005-2015, 2017-2022, 2026, Albert Astals Cid <[email protected]> |
| 5 |
* Copyright (C) 2005, Stefan Kebekus <[email protected]> |
| 6 |
* Copyright (C) 2006-2011, Pino Toscano <[email protected]> |
| 7 |
* Copyright (C) 2009 Shawn Rutledge <[email protected]> |
| 8 |
* Copyright (C) 2010 Suzuki Toshiya <[email protected]> |
| 9 |
* Copyright (C) 2010 Matthias Fauconneau <[email protected]> |
| 10 |
* Copyright (C) 2011 Andreas Hartmetz <[email protected]> |
| 11 |
* Copyright (C) 2011 Glad Deschrijver <[email protected]> |
| 12 |
* Copyright (C) 2012, Guillermo A. Amaral B. <[email protected]> |
| 13 |
* Copyright (C) 2012, Fabio D'Urso <[email protected]> |
| 14 |
* Copyright (C) 2012, Tobias Koenig <[email protected]> |
| 15 |
* Copyright (C) 2012, 2014, 2015, 2018, 2019 Adam Reichold <[email protected]> |
| 16 |
* Copyright (C) 2012, 2013 Thomas Freitag <[email protected]> |
| 17 |
* Copyright (C) 2013 Anthony Granger <[email protected]> |
| 18 |
* Copyright (C) 2016 Jakub Alba <[email protected]> |
| 19 |
* Copyright (C) 2017, 2020, 2021 Oliver Sander <[email protected]> |
| 20 |
* Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich |
| 21 |
* Copyright (C) 2018, 2021 Nelson Benítez León <[email protected]> |
| 22 |
* Copyright (C) 2019 Jan Grulich <[email protected]> |
| 23 |
* Copyright (C) 2019 Alexander Volkov <[email protected]> |
| 24 |
* Copyright (C) 2020 Philipp Knechtges <[email protected]> |
| 25 |
* Copyright (C) 2020 Katarina Behrens <[email protected]> |
| 26 |
* Copyright (C) 2020 Thorsten Behrens <[email protected]> |
| 27 |
* Copyright (C) 2020, 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by Technische Universität Dresden |
| 28 |
* Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. |
| 29 |
* Copyright (C) 2021 Mahmoud Khalil <[email protected]> |
| 30 |
* Copyright (C) 2021 Georgiy Sgibnev <[email protected]>. Work sponsored by lab50.net. |
| 31 |
* Copyright (C) 2022 Martin <[email protected]> |
| 32 |
* Copyright (C) 2023 Kevin Ottens <[email protected]>. Work sponsored by De Bortoli Wines |
| 33 |
* Copyright (C) 2024 Pratham Gandhi <[email protected]> |
| 34 |
* Copyright (C) 2025 Stefan Brüns <[email protected]> |
| 35 |
* |
| 36 |
* This program is free software; you can redistribute it and/or modify |
| 37 |
* it under the terms of the GNU General Public License as published by |
| 38 |
* the Free Software Foundation; either version 2, or (at your option) |
| 39 |
* any later version. |
| 40 |
* |
| 41 |
* This program is distributed in the hope that it will be useful, |
| 42 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 43 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 44 |
* GNU General Public License for more details. |
| 45 |
* |
| 46 |
* You should have received a copy of the GNU General Public License |
| 47 |
* along with this program; if not, write to the Free Software |
| 48 |
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| 49 |
*/ |
| 50 |
|
| 51 |
#ifndef __POPPLER_QT_H__ |
| 52 |
#define __POPPLER_QT_H__ |
| 53 |
|
| 54 |
#include <functional> |
| 55 |
#include <memory> |
| 56 |
#include <vector> |
| 57 |
|
| 58 |
#include "poppler-annotation.h" |
| 59 |
#include "poppler-link.h" |
| 60 |
#include "poppler-optcontent.h" |
| 61 |
#include "poppler-page-transition.h" |
| 62 |
#include "poppler-converter.h" |
| 63 |
|
| 64 |
#include <QtCore/QByteArray> |
| 65 |
#include <QtCore/QDateTime> |
| 66 |
#include <QtCore/QIODevice> |
| 67 |
#include <QtCore/QSet> |
| 68 |
#include "poppler-export.h" |
| 69 |
|
| 70 |
class EmbFile; |
| 71 |
class Sound; |
| 72 |
class AnnotMovie; |
| 73 |
|
| 74 |
/** |
| 75 |
The %Poppler Qt6 binding. |
| 76 |
*/ |
| 77 |
namespace Poppler { |
| 78 |
|
| 79 |
class Document; |
| 80 |
class DocumentData; |
| 81 |
|
| 82 |
class PageData; |
| 83 |
|
| 84 |
class FormField; |
| 85 |
class FormFieldSignature; |
| 86 |
|
| 87 |
class TextBoxData; |
| 88 |
|
| 89 |
class PDFConverter; |
| 90 |
class PSConverter; |
| 91 |
|
| 92 |
struct OutlineItemData; |
| 93 |
|
| 94 |
/** |
| 95 |
Debug/error function. |
| 96 |
|
| 97 |
This function type is used for debugging & error output; |
| 98 |
the first parameter is the actual message, the second is the unaltered |
| 99 |
closure argument which was passed to the setDebugErrorFunction call. |
| 100 |
*/ |
| 101 |
using PopplerDebugFunc = void (*)(const QString & /*message*/, const QVariant & /*closure*/); |
| 102 |
|
| 103 |
/** |
| 104 |
Set a new debug/error output function. |
| 105 |
|
| 106 |
If not set, by default error and debug messages will be sent to the |
| 107 |
Qt \p qDebug() function. |
| 108 |
|
| 109 |
\param debugFunction the new debug function |
| 110 |
\param closure user data which will be passes as-is to the debug function |
| 111 |
*/ |
| 112 |
POPPLER_QT6_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure); |
| 113 |
|
| 114 |
/** |
| 115 |
Describes the physical location of text on a document page |
| 116 |
|
| 117 |
This very simple class describes the physical location of text |
| 118 |
on the page. It consists of |
| 119 |
- a QString that contains the text |
| 120 |
- a QRectF that gives a box that describes where on the page |
| 121 |
the text is found. |
| 122 |
*/ |
| 123 |
class POPPLER_QT6_EXPORT TextBox |
| 124 |
{ |
| 125 |
friend class Page; |
| 126 |
|
| 127 |
public: |
| 128 |
/** |
| 129 |
The default constructor sets the \p text and the rectangle that |
| 130 |
contains the text. Coordinates for the \p bBox are in points = |
| 131 |
1/72 of an inch. |
| 132 |
*/ |
| 133 |
TextBox(const QString &text, const QRectF &bBox); |
| 134 |
/** |
| 135 |
Destructor. |
| 136 |
*/ |
| 137 |
~TextBox(); |
| 138 |
|
| 139 |
/** |
| 140 |
Returns the text of this text box |
| 141 |
*/ |
| 142 |
QString text() const; |
| 143 |
|
| 144 |
/** |
| 145 |
Returns the position of the text, in point, i.e., 1/72 of |
| 146 |
an inch |
| 147 |
*/ |
| 148 |
QRectF boundingBox() const; |
| 149 |
|
| 150 |
/** |
| 151 |
Returns the pointer to the next text box, if there is one. |
| 152 |
|
| 153 |
Otherwise, it returns a null pointer. |
| 154 |
*/ |
| 155 |
TextBox *nextWord() const; |
| 156 |
|
| 157 |
/** |
| 158 |
Returns the bounding box of the \p i -th characted of the word. |
| 159 |
*/ |
| 160 |
QRectF charBoundingBox(int i) const; |
| 161 |
|
| 162 |
/** |
| 163 |
Returns whether there is a space character after this text box |
| 164 |
*/ |
| 165 |
bool hasSpaceAfter() const; |
| 166 |
|
| 167 |
private: |
| 168 |
Q_DISABLE_COPY(TextBox) |
| 169 |
|
| 170 |
TextBoxData *m_data; |
| 171 |
}; |
| 172 |
|
| 173 |
class FontInfoData; |
| 174 |
/** |
| 175 |
Container class for information about a font within a PDF |
| 176 |
document |
| 177 |
*/ |
| 178 |
class POPPLER_QT6_EXPORT FontInfo |
| 179 |
{ |
| 180 |
friend class Document; |
| 181 |
|
| 182 |
public: |
| 183 |
/** |
| 184 |
The type of font. |
| 185 |
*/ |
| 186 |
enum Type |
| 187 |
{ |
| 188 |
unknown, |
| 189 |
Type1, |
| 190 |
Type1C, |
| 191 |
Type1COT, |
| 192 |
Type3, |
| 193 |
TrueType, |
| 194 |
TrueTypeOT, |
| 195 |
CIDType0, |
| 196 |
CIDType0C, |
| 197 |
CIDType0COT, |
| 198 |
CIDTrueType, |
| 199 |
CIDTrueTypeOT |
| 200 |
}; |
| 201 |
|
| 202 |
/// \cond PRIVATE |
| 203 |
/** |
| 204 |
Create a new font information container. |
| 205 |
*/ |
| 206 |
FontInfo(); |
| 207 |
|
| 208 |
/** |
| 209 |
Create a new font information container. |
| 210 |
*/ |
| 211 |
explicit FontInfo(const FontInfoData &fid); |
| 212 |
/// \endcond |
| 213 |
|
| 214 |
/** |
| 215 |
Copy constructor. |
| 216 |
*/ |
| 217 |
FontInfo(const FontInfo &fi); |
| 218 |
|
| 219 |
/** |
| 220 |
Destructor. |
| 221 |
*/ |
| 222 |
~FontInfo(); |
| 223 |
|
| 224 |
/** |
| 225 |
The name of the font. Can be a null QString if the font has no name |
| 226 |
*/ |
| 227 |
QString name() const; |
| 228 |
|
| 229 |
/** |
| 230 |
The name of the substitute font. Can be a null QString if the font has no substitute font |
| 231 |
*/ |
| 232 |
QString substituteName() const; |
| 233 |
|
| 234 |
/** |
| 235 |
The path of the font file used to represent this font on this system, |
| 236 |
or a null string is the font is embedded |
| 237 |
*/ |
| 238 |
QString file() const; |
| 239 |
|
| 240 |
/** |
| 241 |
Whether the font is embedded in the file, or not |
| 242 |
|
| 243 |
\return true if the font is embedded |
| 244 |
*/ |
| 245 |
bool isEmbedded() const; |
| 246 |
|
| 247 |
/** |
| 248 |
Whether the font provided is only a subset of the full |
| 249 |
font or not. This only has meaning if the font is embedded. |
| 250 |
|
| 251 |
\return true if the font is only a subset |
| 252 |
*/ |
| 253 |
bool isSubset() const; |
| 254 |
|
| 255 |
/** |
| 256 |
The type of font encoding |
| 257 |
|
| 258 |
\return a enumerated value corresponding to the font encoding used |
| 259 |
|
| 260 |
\sa typeName for a string equivalent |
| 261 |
*/ |
| 262 |
Type type() const; |
| 263 |
|
| 264 |
/** |
| 265 |
The name of the font encoding used |
| 266 |
|
| 267 |
\note if you are looking for the name of the font (as opposed to the |
| 268 |
encoding format used), you probably want name(). |
| 269 |
|
| 270 |
\sa type for a enumeration version |
| 271 |
*/ |
| 272 |
QString typeName() const; |
| 273 |
|
| 274 |
/** |
| 275 |
Standard assignment operator |
| 276 |
*/ |
| 277 |
FontInfo &operator=(const FontInfo &fi); |
| 278 |
|
| 279 |
private: |
| 280 |
FontInfoData *m_data; |
| 281 |
}; |
| 282 |
|
| 283 |
class FontIteratorData; |
| 284 |
/** |
| 285 |
Iterator for reading the fonts in a document. |
| 286 |
|
| 287 |
FontIterator provides a Java-style iterator for reading the fonts in a |
| 288 |
document. |
| 289 |
|
| 290 |
You can use it in the following way: |
| 291 |
\code |
| 292 |
std::unique_ptr<Poppler::FontIterator> it = doc->newFontIterator(); |
| 293 |
while (it->hasNext()) { |
| 294 |
QList<Poppler::FontInfo> fonts = it->next(); |
| 295 |
// do something with the fonts |
| 296 |
} |
| 297 |
// no need to free the iterator after doing the job |
| 298 |
\endcode |
| 299 |
*/ |
| 300 |
class POPPLER_QT6_EXPORT FontIterator |
| 301 |
{ |
| 302 |
friend class Document; |
| 303 |
friend class DocumentData; |
| 304 |
|
| 305 |
public: |
| 306 |
/** |
| 307 |
Destructor. |
| 308 |
*/ |
| 309 |
~FontIterator(); |
| 310 |
|
| 311 |
/** |
| 312 |
Returns the fonts of the current page and then advances the iterator |
| 313 |
to the next page. |
| 314 |
*/ |
| 315 |
QList<FontInfo> next(); |
| 316 |
|
| 317 |
/** |
| 318 |
Checks whether there is at least one more page to iterate, ie returns |
| 319 |
false when the iterator is beyond the last page. |
| 320 |
*/ |
| 321 |
bool hasNext() const; |
| 322 |
|
| 323 |
/** |
| 324 |
Returns the current page where the iterator is. |
| 325 |
*/ |
| 326 |
int currentPage() const; |
| 327 |
|
| 328 |
private: |
| 329 |
Q_DISABLE_COPY(FontIterator) |
| 330 |
FontIterator(int, DocumentData *dd); |
| 331 |
|
| 332 |
FontIteratorData *d; |
| 333 |
}; |
| 334 |
|
| 335 |
class EmbeddedFileData; |
| 336 |
/** |
| 337 |
Container class for an embedded file with a PDF document |
| 338 |
*/ |
| 339 |
class POPPLER_QT6_EXPORT EmbeddedFile |
| 340 |
{ |
| 341 |
friend class DocumentData; |
| 342 |
friend class AnnotationPrivate; |
| 343 |
|
| 344 |
public: |
| 345 |
/// \cond PRIVATE |
| 346 |
explicit EmbeddedFile(EmbFile *embfile); |
| 347 |
/// \endcond |
| 348 |
|
| 349 |
/** |
| 350 |
Destructor. |
| 351 |
*/ |
| 352 |
~EmbeddedFile(); |
| 353 |
|
| 354 |
/** |
| 355 |
The name associated with the file |
| 356 |
*/ |
| 357 |
QString name() const; |
| 358 |
|
| 359 |
/** |
| 360 |
The description associated with the file, if any. |
| 361 |
|
| 362 |
This will return an empty QString if there is no description element |
| 363 |
*/ |
| 364 |
QString description() const; |
| 365 |
|
| 366 |
/** |
| 367 |
The size of the file. |
| 368 |
|
| 369 |
This will return < 0 if there is no size element |
| 370 |
*/ |
| 371 |
int size() const; |
| 372 |
|
| 373 |
/** |
| 374 |
The modification date for the embedded file, if known. |
| 375 |
*/ |
| 376 |
QDateTime modDate() const; |
| 377 |
|
| 378 |
/** |
| 379 |
The creation date for the embedded file, if known. |
| 380 |
*/ |
| 381 |
QDateTime createDate() const; |
| 382 |
|
| 383 |
/** |
| 384 |
The MD5 checksum of the file. |
| 385 |
|
| 386 |
This will return an empty QByteArray if there is no checksum element. |
| 387 |
*/ |
| 388 |
QByteArray checksum() const; |
| 389 |
|
| 390 |
/** |
| 391 |
The MIME type of the file, if known. |
| 392 |
*/ |
| 393 |
QString mimeType() const; |
| 394 |
|
| 395 |
/** |
| 396 |
The data as a byte array |
| 397 |
*/ |
| 398 |
QByteArray data(); |
| 399 |
|
| 400 |
/** |
| 401 |
Is the embedded file valid? |
| 402 |
*/ |
| 403 |
bool isValid() const; |
| 404 |
|
| 405 |
/** |
| 406 |
A QDataStream for the actual data? |
| 407 |
*/ |
| 408 |
// QDataStream dataStream() const; |
| 409 |
|
| 410 |
private: |
| 411 |
Q_DISABLE_COPY(EmbeddedFile) |
| 412 |
explicit EmbeddedFile(EmbeddedFileData &dd); |
| 413 |
|
| 414 |
EmbeddedFileData *m_embeddedFile; |
| 415 |
}; |
| 416 |
|
| 417 |
/** |
| 418 |
\brief A page in a document. |
| 419 |
|
| 420 |
The Page class represents a single page within a PDF document. |
| 421 |
|
| 422 |
You cannot construct a Page directly, but you have to use the Document |
| 423 |
functions that return a new Page out of an index or a label. |
| 424 |
*/ |
| 425 |
class POPPLER_QT6_EXPORT Page |
| 426 |
{ |
| 427 |
friend class Document; |
| 428 |
|
| 429 |
public: |
| 430 |
/** |
| 431 |
Destructor. |
| 432 |
*/ |
| 433 |
~Page(); |
| 434 |
|
| 435 |
/** |
| 436 |
The type of rotation to apply for an operation |
| 437 |
*/ |
| 438 |
enum Rotation |
| 439 |
{ |
| 440 |
Rotate0 = 0, ///< Do not rotate |
| 441 |
Rotate90 = 1, ///< Rotate 90 degrees clockwise |
| 442 |
Rotate180 = 2, ///< Rotate 180 degrees |
| 443 |
Rotate270 = 3 ///< Rotate 270 degrees clockwise (90 degrees counterclockwise) |
| 444 |
}; |
| 445 |
|
| 446 |
/** |
| 447 |
The kinds of page actions |
| 448 |
*/ |
| 449 |
enum PageAction |
| 450 |
{ |
| 451 |
Opening, ///< The action when a page is "opened" |
| 452 |
Closing ///< The action when a page is "closed" |
| 453 |
}; |
| 454 |
|
| 455 |
/** |
| 456 |
How the text is going to be returned |
| 457 |
*/ |
| 458 |
enum TextLayout |
| 459 |
{ |
| 460 |
PhysicalLayout, ///< The text is layouted to resemble the real page layout |
| 461 |
RawOrderLayout, ///< The text is returned without any type of processing |
| 462 |
ReadingOrder, ///< The text is returned in reading order, \since 26.01 |
| 463 |
}; |
| 464 |
|
| 465 |
/** |
| 466 |
Additional flags for the renderToPainter method |
| 467 |
*/ |
| 468 |
enum PainterFlag |
| 469 |
{ |
| 470 |
NoPainterFlags = 0x00000000, |
| 471 |
/** |
| 472 |
Do not save/restore the caller-owned painter. |
| 473 |
|
| 474 |
renderToPainter() by default preserves, using save() + restore(), |
| 475 |
the state of the painter specified; if this is not needed, this |
| 476 |
flag can avoid this job |
| 477 |
*/ |
| 478 |
DontSaveAndRestore = 0x00000001 |
| 479 |
}; |
| 480 |
Q_DECLARE_FLAGS(PainterFlags, PainterFlag) |
| 481 |
|
| 482 |
/** |
| 483 |
Render the page to a QImage using the current |
| 484 |
\link Document::renderBackend() Document renderer\endlink. |
| 485 |
|
| 486 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 487 |
compute the size of the image from the horizontal and vertical |
| 488 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 489 |
method renders only a part of the page, specified by the |
| 490 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned |
| 491 |
QImage then has size (\p w, \p h), independent of the page |
| 492 |
size. |
| 493 |
|
| 494 |
\param x specifies the left x-coordinate of the box, in |
| 495 |
pixels. |
| 496 |
|
| 497 |
\param y specifies the top y-coordinate of the box, in |
| 498 |
pixels. |
| 499 |
|
| 500 |
\param w specifies the width of the box, in pixels. |
| 501 |
|
| 502 |
\param h specifies the height of the box, in pixels. |
| 503 |
|
| 504 |
\param xres horizontal resolution of the graphics device, |
| 505 |
in dots per inch |
| 506 |
|
| 507 |
\param yres vertical resolution of the graphics device, in |
| 508 |
dots per inch |
| 509 |
|
| 510 |
\param rotate how to rotate the page |
| 511 |
|
| 512 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 513 |
well-tested. Unusual or meaningless parameters may lead to |
| 514 |
rather unexpected results. |
| 515 |
|
| 516 |
\returns a QImage of the page, or a null image on failure. |
| 517 |
*/ |
| 518 |
QImage renderToImage(double xres = 72.0, double yres = 72.0, int x = -1, int y = -1, int w = -1, int h = -1, Rotation rotate = Rotate0) const; |
| 519 |
|
| 520 |
/** |
| 521 |
Partial Update renderToImage callback. |
| 522 |
|
| 523 |
This function type is used for doing partial rendering updates; |
| 524 |
the first parameter is the image as rendered up to now, the second is the unaltered |
| 525 |
closure argument which was passed to the renderToImage call. |
| 526 |
*/ |
| 527 |
using RenderToImagePartialUpdateFunc = void (*)(const QImage & /*image*/, const QVariant & /*closure*/); |
| 528 |
|
| 529 |
/** |
| 530 |
Partial Update query renderToImage callback. |
| 531 |
|
| 532 |
This function type is used for query if the partial rendering update should happen; |
| 533 |
the parameter is the unaltered closure argument which was passed to the renderToImage call. |
| 534 |
*/ |
| 535 |
using ShouldRenderToImagePartialQueryFunc = bool (*)(const QVariant & /*closure*/); |
| 536 |
|
| 537 |
/** |
| 538 |
Render the page to a QImage using the current |
| 539 |
\link Document::renderBackend() Document renderer\endlink. |
| 540 |
|
| 541 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 542 |
compute the size of the image from the horizontal and vertical |
| 543 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 544 |
method renders only a part of the page, specified by the |
| 545 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned |
| 546 |
QImage then has size (\p w, \p h), independent of the page |
| 547 |
size. |
| 548 |
|
| 549 |
\param x specifies the left x-coordinate of the box, in |
| 550 |
pixels. |
| 551 |
|
| 552 |
\param y specifies the top y-coordinate of the box, in |
| 553 |
pixels. |
| 554 |
|
| 555 |
\param w specifies the width of the box, in pixels. |
| 556 |
|
| 557 |
\param h specifies the height of the box, in pixels. |
| 558 |
|
| 559 |
\param xres horizontal resolution of the graphics device, |
| 560 |
in dots per inch |
| 561 |
|
| 562 |
\param yres vertical resolution of the graphics device, in |
| 563 |
dots per inch |
| 564 |
|
| 565 |
\param rotate how to rotate the page |
| 566 |
|
| 567 |
\param partialUpdateCallback callback that will be called to |
| 568 |
report a partial rendering update |
| 569 |
|
| 570 |
\param shouldDoPartialUpdateCallback callback that will be called |
| 571 |
to ask if a partial rendering update is wanted. This exists |
| 572 |
because doing a partial rendering update needs to copy the image |
| 573 |
buffer so if it is not wanted it is better skipped early. |
| 574 |
|
| 575 |
\param payload opaque structure that will be passed |
| 576 |
back to partialUpdateCallback and shouldDoPartialUpdateCallback. |
| 577 |
|
| 578 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 579 |
well-tested. Unusual or meaningless parameters may lead to |
| 580 |
rather unexpected results. |
| 581 |
|
| 582 |
\returns a QImage of the page, or a null image on failure. |
| 583 |
*/ |
| 584 |
QImage renderToImage(double xres, double yres, int x, int y, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, |
| 585 |
const QVariant &payload) const; |
| 586 |
|
| 587 |
/** |
| 588 |
Abort query function callback. |
| 589 |
|
| 590 |
This function type is used for query if the current rendering/text extraction should be cancelled. |
| 591 |
*/ |
| 592 |
using ShouldAbortQueryFunc = bool (*)(const QVariant & /*closure*/); |
| 593 |
|
| 594 |
/** |
| 595 |
Render the page to a QImage using the current |
| 596 |
\link Document::renderBackend() Document renderer\endlink. |
| 597 |
|
| 598 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 599 |
compute the size of the image from the horizontal and vertical |
| 600 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 601 |
method renders only a part of the page, specified by the |
| 602 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned |
| 603 |
QImage then has size (\p w, \p h), independent of the page |
| 604 |
size. |
| 605 |
|
| 606 |
\param x specifies the left x-coordinate of the box, in |
| 607 |
pixels. |
| 608 |
|
| 609 |
\param y specifies the top y-coordinate of the box, in |
| 610 |
pixels. |
| 611 |
|
| 612 |
\param w specifies the width of the box, in pixels. |
| 613 |
|
| 614 |
\param h specifies the height of the box, in pixels. |
| 615 |
|
| 616 |
\param xres horizontal resolution of the graphics device, |
| 617 |
in dots per inch |
| 618 |
|
| 619 |
\param yres vertical resolution of the graphics device, in |
| 620 |
dots per inch |
| 621 |
|
| 622 |
\param rotate how to rotate the page |
| 623 |
|
| 624 |
\param partialUpdateCallback callback that will be called to |
| 625 |
report a partial rendering update |
| 626 |
|
| 627 |
\param shouldDoPartialUpdateCallback callback that will be called |
| 628 |
to ask if a partial rendering update is wanted. This exists |
| 629 |
because doing a partial rendering update needs to copy the image |
| 630 |
buffer so if it is not wanted it is better skipped early. |
| 631 |
|
| 632 |
\param shouldAbortRenderCallback callback that will be called |
| 633 |
to ask if the rendering should be cancelled. |
| 634 |
|
| 635 |
\param payload opaque structure that will be passed |
| 636 |
back to partialUpdateCallback, shouldDoPartialUpdateCallback |
| 637 |
and shouldAbortRenderCallback. |
| 638 |
|
| 639 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 640 |
well-tested. Unusual or meaningless parameters may lead to |
| 641 |
rather unexpected results. |
| 642 |
|
| 643 |
\returns a QImage of the page, or a null image on failure. |
| 644 |
*/ |
| 645 |
QImage renderToImage(double xres, double yres, int x, int y, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, |
| 646 |
ShouldAbortQueryFunc shouldAbortRenderCallback, const QVariant &payload) const; |
| 647 |
|
| 648 |
/** |
| 649 |
Render the page to the specified QPainter using the current |
| 650 |
\link Document::renderBackend() Document renderer\endlink. |
| 651 |
|
| 652 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 653 |
compute the size of the page area from the horizontal and vertical |
| 654 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 655 |
method renders only a part of the page, specified by the |
| 656 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. |
| 657 |
|
| 658 |
\param painter the painter to paint on |
| 659 |
|
| 660 |
\param x specifies the left x-coordinate of the box, in |
| 661 |
pixels. |
| 662 |
|
| 663 |
\param y specifies the top y-coordinate of the box, in |
| 664 |
pixels. |
| 665 |
|
| 666 |
\param w specifies the width of the box, in pixels. |
| 667 |
|
| 668 |
\param h specifies the height of the box, in pixels. |
| 669 |
|
| 670 |
\param xres horizontal resolution of the graphics device, |
| 671 |
in dots per inch |
| 672 |
|
| 673 |
\param yres vertical resolution of the graphics device, in |
| 674 |
dots per inch |
| 675 |
|
| 676 |
\param rotate how to rotate the page |
| 677 |
|
| 678 |
\param flags additional painter flags |
| 679 |
|
| 680 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 681 |
well-tested. Unusual or meaningless parameters may lead to |
| 682 |
rather unexpected results. |
| 683 |
|
| 684 |
\returns whether the painting succeeded |
| 685 |
|
| 686 |
\note This method is only supported for the QPainterOutputDev |
| 687 |
*/ |
| 688 |
bool renderToPainter(QPainter *painter, double xres = 72.0, double yres = 72.0, int x = -1, int y = -1, int w = -1, int h = -1, Rotation rotate = Rotate0, PainterFlags flags = NoPainterFlags) const; |
| 689 |
|
| 690 |
/** |
| 691 |
Get the page thumbnail if it exists. |
| 692 |
|
| 693 |
\return a QImage of the thumbnail, or a null image |
| 694 |
if the PDF does not contain one for this page |
| 695 |
*/ |
| 696 |
QImage thumbnail() const; |
| 697 |
|
| 698 |
/** |
| 699 |
Returns the text that is inside a specified rectangle |
| 700 |
|
| 701 |
\param rect the rectangle specifying the area of interest, |
| 702 |
with coordinates given in points, i.e., 1/72th of an inch. |
| 703 |
If rect is null, all text on the page is given |
| 704 |
|
| 705 |
\param textLayout the layouting that should be applied to the text. |
| 706 |
ReadingOrder is not supported with non null rect |
| 707 |
|
| 708 |
**/ |
| 709 |
QString text(const QRectF &rect, TextLayout textLayout) const; |
| 710 |
|
| 711 |
/** |
| 712 |
Returns the text that is inside a specified rectangle. |
| 713 |
The text is returned using the physical layout of the page |
| 714 |
|
| 715 |
\param rect the rectangle specifying the area of interest, |
| 716 |
with coordinates given in points, i.e., 1/72th of an inch. |
| 717 |
If rect is null, all text on the page is given |
| 718 |
**/ |
| 719 |
QString text(const QRectF &rect) const; |
| 720 |
|
| 721 |
/** |
| 722 |
The starting point for a search |
| 723 |
*/ |
| 724 |
enum SearchDirection |
| 725 |
{ |
| 726 |
FromTop, ///< Start sorting at the top of the document |
| 727 |
NextResult, ///< Find the next result, moving "down the page" |
| 728 |
PreviousResult ///< Find the previous result, moving "up the page" |
| 729 |
}; |
| 730 |
|
| 731 |
/** |
| 732 |
The type of search to perform |
| 733 |
*/ |
| 734 |
enum SearchMode |
| 735 |
{ |
| 736 |
CaseSensitive, ///< Case differences cause no match in searching |
| 737 |
CaseInsensitive ///< Case differences are ignored in matching |
| 738 |
}; |
| 739 |
|
| 740 |
/** |
| 741 |
Flags to modify the search behaviour |
| 742 |
*/ |
| 743 |
enum SearchFlag |
| 744 |
{ |
| 745 |
NoSearchFlags = 0x00000000, |
| 746 |
IgnoreCase = 0x00000001, ///< Case differences are ignored |
| 747 |
WholeWords = 0x00000002, ///< Only whole words are matched |
| 748 |
IgnoreDiacritics = 0x00000004, ///< Diacritic differences (eg. accents, umlauts, diaeresis) are ignored. |
| 749 |
///< This option will have no effect if the search term contains characters which |
| 750 |
///< are not pure ascii. |
| 751 |
AcrossLines = 0x00000008 ///< Allows to match on text spanning from end of a line to the next line. |
| 752 |
///< It won't match on text spanning more than two lines. Automatically ignores hyphen |
| 753 |
///< at end of line, and allows whitespace in search term to match on newline. \since 21.05.0 |
| 754 |
}; |
| 755 |
Q_DECLARE_FLAGS(SearchFlags, SearchFlag) |
| 756 |
|
| 757 |
/** |
| 758 |
Returns true if the specified text was found. |
| 759 |
|
| 760 |
\param text the text the search |
| 761 |
\param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult |
| 762 |
indicates where to continue searching for |
| 763 |
\param direction in which direction do the search |
| 764 |
\param flags the flags to consider during matching |
| 765 |
\param rotate the rotation to apply for the search order |
| 766 |
**/ |
| 767 |
bool search(const QString &text, double &sLeft, double &sTop, double &sRight, double &sBottom, SearchDirection direction, SearchFlags flags = NoSearchFlags, Rotation rotate = Rotate0) const; |
| 768 |
|
| 769 |
/** |
| 770 |
Returns a list of all occurrences of the specified text on the page. |
| 771 |
|
| 772 |
if SearchFlags::AcrossLines is given in \param flags, then rects may just |
| 773 |
be parts of the text itself if it's split between multiple lines. |
| 774 |
|
| 775 |
\param text the text to search |
| 776 |
\param flags the flags to consider during matching |
| 777 |
\param rotate the rotation to apply for the search order |
| 778 |
|
| 779 |
\warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. |
| 780 |
**/ |
| 781 |
QList<QRectF> search(const QString &text, SearchFlags flags = NoSearchFlags, Rotation rotate = Rotate0) const; |
| 782 |
|
| 783 |
/** |
| 784 |
Returns a list of text of the page |
| 785 |
|
| 786 |
This method returns a QList of TextBoxes that contain all |
| 787 |
the text of the page, with roughly one text word of text |
| 788 |
per TextBox item. |
| 789 |
|
| 790 |
For text written in western languages (left-to-right and |
| 791 |
up-to-down), the QList contains the text in the proper |
| 792 |
order. |
| 793 |
|
| 794 |
\warning This method is not tested with Asian scripts |
| 795 |
*/ |
| 796 |
std::vector<std::unique_ptr<TextBox>> textList(Rotation rotate = Rotate0) const; |
| 797 |
|
| 798 |
/** |
| 799 |
Returns a list of text of the page |
| 800 |
|
| 801 |
This method returns a QList of TextBoxes that contain all |
| 802 |
the text of the page, with roughly one text word of text |
| 803 |
per TextBox item. |
| 804 |
|
| 805 |
For text written in western languages (left-to-right and |
| 806 |
up-to-down), the QList contains the text in the proper |
| 807 |
order. |
| 808 |
|
| 809 |
\param shouldAbortExtractionCallback callback that will be called |
| 810 |
to ask if the text extraction should be cancelled. |
| 811 |
|
| 812 |
\param closure opaque structure that will be passed |
| 813 |
back to shouldAbortExtractionCallback. |
| 814 |
|
| 815 |
\warning This method is not tested with Asian scripts |
| 816 |
*/ |
| 817 |
std::vector<std::unique_ptr<TextBox>> textList(Rotation rotate, ShouldAbortQueryFunc shouldAbortExtractionCallback, const QVariant &closure) const; |
| 818 |
|
| 819 |
/** |
| 820 |
\return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) |
| 821 |
*/ |
| 822 |
QSizeF pageSizeF() const; |
| 823 |
|
| 824 |
/** |
| 825 |
\return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) |
| 826 |
*/ |
| 827 |
QSize pageSize() const; |
| 828 |
|
| 829 |
/** |
| 830 |
Returns the transition of this page |
| 831 |
|
| 832 |
\returns a pointer to a PageTransition structure that |
| 833 |
defines how transition to this page shall be performed. |
| 834 |
|
| 835 |
\note The PageTransition structure is owned by this page, and will |
| 836 |
automatically be destroyed when this page class is |
| 837 |
destroyed. |
| 838 |
**/ |
| 839 |
PageTransition *transition() const; |
| 840 |
|
| 841 |
/** |
| 842 |
Gets the page action specified, or empty unique pointer if there is no action. |
| 843 |
**/ |
| 844 |
std::unique_ptr<Link> action(PageAction act) const; |
| 845 |
|
| 846 |
/** |
| 847 |
Types of orientations that are possible |
| 848 |
*/ |
| 849 |
enum Orientation |
| 850 |
{ |
| 851 |
Landscape, ///< Landscape orientation (portrait, with 90 degrees clockwise rotation ) |
| 852 |
Portrait, ///< Normal portrait orientation |
| 853 |
Seascape, ///< Seascape orientation (portrait, with 270 degrees clockwise rotation) |
| 854 |
UpsideDown ///< Upside down orientation (portrait, with 180 degrees rotation) |
| 855 |
}; |
| 856 |
|
| 857 |
/** |
| 858 |
The orientation of the page |
| 859 |
*/ |
| 860 |
Orientation orientation() const; |
| 861 |
|
| 862 |
/** |
| 863 |
The default CTM |
| 864 |
*/ |
| 865 |
void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown); |
| 866 |
|
| 867 |
/** |
| 868 |
Gets the links of the page |
| 869 |
*/ |
| 870 |
std::vector<std::unique_ptr<Link>> links() const; |
| 871 |
|
| 872 |
/** |
| 873 |
Returns the annotations of the page |
| 874 |
|
| 875 |
\note If you call this method twice, you get different objects |
| 876 |
pointing to the same annotations (see Annotation). |
| 877 |
*/ |
| 878 |
std::vector<std::unique_ptr<Annotation>> annotations() const; |
| 879 |
|
| 880 |
/** |
| 881 |
Returns the annotations of the page |
| 882 |
|
| 883 |
\param subtypes the subtypes of annotations you are interested in |
| 884 |
|
| 885 |
\note If you call this method twice, you get different objects |
| 886 |
pointing to the same annotations (see Annotation). |
| 887 |
*/ |
| 888 |
std::vector<std::unique_ptr<Annotation>> annotations(const QSet<Annotation::SubType> &subtypes) const; |
| 889 |
|
| 890 |
/** |
| 891 |
Adds an annotation to the page |
| 892 |
|
| 893 |
\note Ownership of the annotation object stays with the caller, who can |
| 894 |
delete it at any time. |
| 895 |
*/ |
| 896 |
void addAnnotation(const Annotation *ann); |
| 897 |
|
| 898 |
/** |
| 899 |
Removes an annotation from the page and destroys the annotation object |
| 900 |
|
| 901 |
\note There mustn't be other Annotation objects pointing this annotation |
| 902 |
*/ |
| 903 |
void removeAnnotation(const Annotation *ann); |
| 904 |
|
| 905 |
/** |
| 906 |
Returns the form fields on the page |
| 907 |
*/ |
| 908 |
std::vector<std::unique_ptr<FormField>> formFields() const; |
| 909 |
|
| 910 |
/** |
| 911 |
Returns the page duration. That is the time, in seconds, that the page |
| 912 |
should be displayed before the presentation automatically advances to the next page. |
| 913 |
Returns < 0 if duration is not set. |
| 914 |
*/ |
| 915 |
double duration() const; |
| 916 |
|
| 917 |
/** |
| 918 |
Returns the label of the page, or a null string is the page has no label. |
| 919 |
**/ |
| 920 |
QString label() const; |
| 921 |
|
| 922 |
/** |
| 923 |
Returns the index of the page. |
| 924 |
**/ |
| 925 |
int index() const; |
| 926 |
|
| 927 |
private: |
| 928 |
Q_DISABLE_COPY(Page) |
| 929 |
|
| 930 |
Page(DocumentData *doc, int index); |
| 931 |
PageData *m_page; |
| 932 |
}; |
| 933 |
|
| 934 |
/** |
| 935 |
\brief Item in the outline of a PDF document |
| 936 |
|
| 937 |
Represents an item in the outline of PDF document, i.e. a name, an internal or external link and a set of child items. |
| 938 |
**/ |
| 939 |
class POPPLER_QT6_EXPORT OutlineItem |
| 940 |
{ |
| 941 |
friend class Document; |
| 942 |
|
| 943 |
public: |
| 944 |
/** |
| 945 |
Constructs a null item, i.e. one that does not represent a valid item in the outline of some PDF document. |
| 946 |
**/ |
| 947 |
OutlineItem(); |
| 948 |
~OutlineItem(); |
| 949 |
|
| 950 |
OutlineItem(const OutlineItem &other); |
| 951 |
OutlineItem &operator=(const OutlineItem &other); |
| 952 |
|
| 953 |
OutlineItem(OutlineItem &&other) noexcept; |
| 954 |
OutlineItem &operator=(OutlineItem &&other) noexcept; |
| 955 |
|
| 956 |
/** |
| 957 |
Indicates whether an item is null, i.e. whether it does not represent a valid item in the outline of some PDF document. |
| 958 |
**/ |
| 959 |
bool isNull() const; |
| 960 |
|
| 961 |
/** |
| 962 |
The name of the item which should be displayed to the user. |
| 963 |
**/ |
| 964 |
QString name() const; |
| 965 |
|
| 966 |
/** |
| 967 |
Indicates whether the item should initially be display in an expanded or collapsed state. |
| 968 |
**/ |
| 969 |
bool isOpen() const; |
| 970 |
|
| 971 |
/** |
| 972 |
The destination referred to by this item. |
| 973 |
|
| 974 |
\returns a shared pointer to an immutable link destination |
| 975 |
**/ |
| 976 |
QSharedPointer<const LinkDestination> destination() const; |
| 977 |
|
| 978 |
/** |
| 979 |
The external file name of the document to which the \see destination refers |
| 980 |
|
| 981 |
\returns a string with the external file name or an empty string if there is none |
| 982 |
*/ |
| 983 |
QString externalFileName() const; |
| 984 |
|
| 985 |
/** |
| 986 |
The URI to which the item links |
| 987 |
|
| 988 |
\returns a string with the URI which this item links or an empty string if there is none |
| 989 |
**/ |
| 990 |
QString uri() const; |
| 991 |
|
| 992 |
/** |
| 993 |
Determines if this item has any child items |
| 994 |
|
| 995 |
\returns true if there are any child items |
| 996 |
**/ |
| 997 |
bool hasChildren() const; |
| 998 |
|
| 999 |
/** |
| 1000 |
Gets the child items of this item |
| 1001 |
|
| 1002 |
\returns a vector outline items, empty if there are none |
| 1003 |
**/ |
| 1004 |
QVector<OutlineItem> children() const; |
| 1005 |
|
| 1006 |
private: |
| 1007 |
explicit OutlineItem(OutlineItemData *data); |
| 1008 |
OutlineItemData *m_data; |
| 1009 |
}; |
| 1010 |
|
| 1011 |
/** |
| 1012 |
\brief PDF document. |
| 1013 |
|
| 1014 |
The Document class represents a PDF document: its pages, and all the global |
| 1015 |
properties, metadata, etc. |
| 1016 |
|
| 1017 |
\section ownership Ownership of the returned objects |
| 1018 |
|
| 1019 |
All the functions that returns class pointers create new object, and the |
| 1020 |
responsibility of those is given to the caller. |
| 1021 |
|
| 1022 |
The only exception is \link Poppler::Page::transition() Page::transition()\endlink. |
| 1023 |
|
| 1024 |
\section document-loading Loading |
| 1025 |
|
| 1026 |
To get a Document, you have to load it via the load() & loadFromData() |
| 1027 |
functions. |
| 1028 |
|
| 1029 |
In all the functions that have passwords as arguments, they \b must be Latin1 |
| 1030 |
encoded. If you have a password that is a UTF-8 string, you need to use |
| 1031 |
QString::toLatin1() (or similar) to convert the password first. |
| 1032 |
If you have a UTF-8 character array, consider converting it to a QString first |
| 1033 |
(QString::fromUtf8(), or similar) before converting to Latin1 encoding. |
| 1034 |
|
| 1035 |
\section document-rendering Rendering |
| 1036 |
|
| 1037 |
To render pages of a document, you have different Document functions to set |
| 1038 |
various options. |
| 1039 |
|
| 1040 |
\subsection document-rendering-backend Backends |
| 1041 |
|
| 1042 |
%Poppler offers a different backends for rendering the pages. Currently |
| 1043 |
there are two backends (see #RenderBackend), but only the Splash engine works |
| 1044 |
well and has been tested. |
| 1045 |
|
| 1046 |
The available rendering backends can be discovered via availableRenderBackends(). |
| 1047 |
The current rendering backend can be changed using setRenderBackend(). |
| 1048 |
Please note that setting a backend not listed in the available ones |
| 1049 |
will always result in null QImage's. |
| 1050 |
|
| 1051 |
\section document-cms Color management support |
| 1052 |
|
| 1053 |
%Poppler, if compiled with this support, provides functions to handle color |
| 1054 |
profiles. |
| 1055 |
|
| 1056 |
To know whether the %Poppler version you are using has support for color |
| 1057 |
management, you can query Poppler::isCmsAvailable(). In case it is not |
| 1058 |
available, all the color management-related functions will either do nothing |
| 1059 |
or return null. |
| 1060 |
*/ |
| 1061 |
class POPPLER_QT6_EXPORT Document |
| 1062 |
{ |
| 1063 |
friend class Page; |
| 1064 |
friend class DocumentData; |
| 1065 |
|
| 1066 |
public: |
| 1067 |
/** |
| 1068 |
The page mode |
| 1069 |
*/ |
| 1070 |
enum PageMode |
| 1071 |
{ |
| 1072 |
UseNone, ///< No mode - neither document outline nor thumbnail images are visible |
| 1073 |
UseOutlines, ///< Document outline visible |
| 1074 |
UseThumbs, ///< Thumbnail images visible |
| 1075 |
FullScreen, ///< Fullscreen mode (no menubar, windows controls etc) |
| 1076 |
UseOC, ///< Optional content group panel visible |
| 1077 |
UseAttach ///< Attachments panel visible |
| 1078 |
}; |
| 1079 |
|
| 1080 |
/** |
| 1081 |
The page layout |
| 1082 |
*/ |
| 1083 |
enum PageLayout |
| 1084 |
{ |
| 1085 |
NoLayout, ///< Layout not specified |
| 1086 |
SinglePage, ///< Display a single page |
| 1087 |
OneColumn, ///< Display a single column of pages |
| 1088 |
TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left |
| 1089 |
TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right |
| 1090 |
TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left |
| 1091 |
TwoPageRight ///< Display the pages two at a time, with odd-numbered pages on the right |
| 1092 |
}; |
| 1093 |
|
| 1094 |
/** |
| 1095 |
The render backends available |
| 1096 |
*/ |
| 1097 |
enum RenderBackend |
| 1098 |
{ |
| 1099 |
SplashBackend, ///< Splash backend |
| 1100 |
QPainterBackend ///< Qt backend |
| 1101 |
}; |
| 1102 |
|
| 1103 |
/** |
| 1104 |
The render hints available |
| 1105 |
*/ |
| 1106 |
enum RenderHint |
| 1107 |
{ |
| 1108 |
Antialiasing = 0x00000001, ///< Antialiasing for graphics |
| 1109 |
TextAntialiasing = 0x00000002, ///< Antialiasing for text |
| 1110 |
TextHinting = 0x00000004, ///< Hinting for text |
| 1111 |
TextSlightHinting = 0x00000008, ///< Lighter hinting for text when combined with TextHinting |
| 1112 |
OverprintPreview = 0x00000010, ///< Overprint preview |
| 1113 |
ThinLineSolid = 0x00000020, ///< Enhance thin lines solid |
| 1114 |
ThinLineShape = 0x00000040, ///< Enhance thin lines shape. Wins over ThinLineSolid |
| 1115 |
IgnorePaperColor = 0x00000080, ///< Do not compose with the paper color |
| 1116 |
HideAnnotations = 0x00000100 ///< Do not render annotations |
| 1117 |
}; |
| 1118 |
Q_DECLARE_FLAGS(RenderHints, RenderHint) |
| 1119 |
|
| 1120 |
/** |
| 1121 |
Form types |
| 1122 |
*/ |
| 1123 |
enum FormType |
| 1124 |
{ |
| 1125 |
NoForm, ///< Document doesn't contain forms |
| 1126 |
AcroForm, ///< AcroForm |
| 1127 |
XfaForm ///< Adobe XML Forms Architecture (XFA), currently unsupported |
| 1128 |
}; |
| 1129 |
|
| 1130 |
/** |
| 1131 |
Set a color display profile for the current document. |
| 1132 |
|
| 1133 |
\param outputProfileA is a \c cmsHPROFILE of the LCMS library. |
| 1134 |
|
| 1135 |
\note This should be called before any rendering happens. |
| 1136 |
|
| 1137 |
\note It is assumed that poppler takes over the owernship of the corresponding cmsHPROFILE. In particular, |
| 1138 |
it is no longer the caller's responsibility to close the profile after use. |
| 1139 |
*/ |
| 1140 |
void setColorDisplayProfile(void *outputProfileA); |
| 1141 |
/** |
| 1142 |
Set a color display profile for the current document. |
| 1143 |
|
| 1144 |
\param name is the name of the display profile to set. |
| 1145 |
|
| 1146 |
\note This should be called before any rendering happens. |
| 1147 |
*/ |
| 1148 |
void setColorDisplayProfileName(const QString &name); |
| 1149 |
/** |
| 1150 |
Return the current RGB profile. |
| 1151 |
|
| 1152 |
\return a \c cmsHPROFILE of the LCMS library. |
| 1153 |
|
| 1154 |
\note The returned profile stays a property of poppler and shall NOT be closed by the user. It's |
| 1155 |
existence is guaranteed for as long as this instance of the Document class is not deleted. |
| 1156 |
*/ |
| 1157 |
void *colorRgbProfile() const; |
| 1158 |
/** |
| 1159 |
Return the current display profile. |
| 1160 |
|
| 1161 |
\return a \c cmsHPROFILE of the LCMS library. |
| 1162 |
|
| 1163 |
\note The returned profile stays a property of poppler and shall NOT be closed by the user. It's |
| 1164 |
existence is guaranteed for as long as this instance of the Document class is not deleted. |
| 1165 |
*/ |
| 1166 |
void *colorDisplayProfile() const; |
| 1167 |
|
| 1168 |
/** |
| 1169 |
Load the document from a file on disk |
| 1170 |
|
| 1171 |
\param filePath the name (and path, if required) of the file to load |
| 1172 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1173 |
loading the file |
| 1174 |
\param userPassword the Latin1-encoded user ("open") password |
| 1175 |
to use in loading the file |
| 1176 |
|
| 1177 |
\return the loaded document, or empty unique pointer on error |
| 1178 |
|
| 1179 |
\warning The returning document may be locked if a password is required |
| 1180 |
to open the file, and one is not provided (as the userPassword). |
| 1181 |
*/ |
| 1182 |
static std::unique_ptr<Document> load(const QString &filePath, const QByteArray &ownerPassword = QByteArray(), const QByteArray &userPassword = QByteArray()); |
| 1183 |
|
| 1184 |
/** |
| 1185 |
Load the document from a device |
| 1186 |
|
| 1187 |
\param device the device of the data to load |
| 1188 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1189 |
loading the file |
| 1190 |
\param userPassword the Latin1-encoded user ("open") password |
| 1191 |
to use in loading the file |
| 1192 |
|
| 1193 |
\return the loaded document, or empty unique pointer on error |
| 1194 |
|
| 1195 |
\note if the file is on disk it is recommended to use the other load overload |
| 1196 |
since it is less resource intensive |
| 1197 |
|
| 1198 |
\warning The returning document may be locked if a password is required |
| 1199 |
to open the file, and one is not provided (as the userPassword). |
| 1200 |
*/ |
| 1201 |
static std::unique_ptr<Document> load(QIODevice *device, const QByteArray &ownerPassword = QByteArray(), const QByteArray &userPassword = QByteArray()); |
| 1202 |
|
| 1203 |
/** |
| 1204 |
Load the document from memory |
| 1205 |
|
| 1206 |
\param fileContents the file contents. They are copied so there is no need |
| 1207 |
to keep the byte array around for the full life time of |
| 1208 |
the document. |
| 1209 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1210 |
loading the file |
| 1211 |
\param userPassword the Latin1-encoded user ("open") password |
| 1212 |
to use in loading the file |
| 1213 |
|
| 1214 |
\return the loaded document, or empty unique pointer on error |
| 1215 |
|
| 1216 |
\warning The returning document may be locked if a password is required |
| 1217 |
to open the file, and one is not provided (as the userPassword). |
| 1218 |
*/ |
| 1219 |
static std::unique_ptr<Document> loadFromData(const QByteArray &fileContents, const QByteArray &ownerPassword = QByteArray(), const QByteArray &userPassword = QByteArray()); |
| 1220 |
|
| 1221 |
/** |
| 1222 |
Get a specified Page |
| 1223 |
|
| 1224 |
Note that this follows the PDF standard of being zero based - if you |
| 1225 |
want the first page, then you need an index of zero. |
| 1226 |
|
| 1227 |
This function can return empty unique pointer if for some reason the page can't be properly parsed. |
| 1228 |
|
| 1229 |
\param index the page number index |
| 1230 |
|
| 1231 |
\warning The Page object returned by this method internally stores a pointer |
| 1232 |
to the document that it was created from. This pointer will go stale if you |
| 1233 |
delete the Document object. Therefore the Document object needs to be kept alive |
| 1234 |
as long as you want to use the Page object. |
| 1235 |
*/ |
| 1236 |
std::unique_ptr<Page> page(int index) const; |
| 1237 |
|
| 1238 |
/** |
| 1239 |
\overload |
| 1240 |
|
| 1241 |
|
| 1242 |
The intent is that you can pass in a label like \c "ix" and |
| 1243 |
get the page with that label (which might be in the table of |
| 1244 |
contents), or pass in \c "1" and get the page that the user |
| 1245 |
expects (which might not be the first page, if there is a |
| 1246 |
title page and a table of contents). |
| 1247 |
|
| 1248 |
\param label the page label |
| 1249 |
*/ |
| 1250 |
std::unique_ptr<Page> page(const QString &label) const; |
| 1251 |
|
| 1252 |
/** |
| 1253 |
The number of pages in the document |
| 1254 |
*/ |
| 1255 |
int numPages() const; |
| 1256 |
|
| 1257 |
/** |
| 1258 |
The type of mode that should be used by the application |
| 1259 |
when the document is opened. Note that while this is |
| 1260 |
called page mode, it is really viewer application mode. |
| 1261 |
*/ |
| 1262 |
PageMode pageMode() const; |
| 1263 |
|
| 1264 |
/** |
| 1265 |
The layout that pages should be shown in when the document |
| 1266 |
is first opened. This basically describes how pages are |
| 1267 |
shown relative to each other. |
| 1268 |
*/ |
| 1269 |
PageLayout pageLayout() const; |
| 1270 |
|
| 1271 |
/** |
| 1272 |
The predominant reading order for text as supplied by |
| 1273 |
the document's viewer preferences. |
| 1274 |
*/ |
| 1275 |
Qt::LayoutDirection textDirection() const; |
| 1276 |
|
| 1277 |
/** |
| 1278 |
Provide the passwords required to unlock the document |
| 1279 |
|
| 1280 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1281 |
loading the file |
| 1282 |
\param userPassword the Latin1-encoded user ("open") password |
| 1283 |
to use in loading the file |
| 1284 |
*/ |
| 1285 |
bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword); |
| 1286 |
|
| 1287 |
/** |
| 1288 |
Determine if the document is locked |
| 1289 |
*/ |
| 1290 |
bool isLocked() const; |
| 1291 |
|
| 1292 |
/** |
| 1293 |
The date associated with the document |
| 1294 |
|
| 1295 |
You would use this method with something like: |
| 1296 |
\code |
| 1297 |
QDateTime created = m_doc->date("CreationDate"); |
| 1298 |
QDateTime modified = m_doc->date("ModDate"); |
| 1299 |
\endcode |
| 1300 |
|
| 1301 |
The available dates are: |
| 1302 |
- CreationDate: the date of creation of the document |
| 1303 |
- ModDate: the date of the last change in the document |
| 1304 |
|
| 1305 |
\param type the type of date that is required |
| 1306 |
*/ |
| 1307 |
QDateTime date(const QString &type) const; |
| 1308 |
|
| 1309 |
/** |
| 1310 |
Set the Info dict date entry specified by \param key to \param val |
| 1311 |
|
| 1312 |
\returns true on success, false on failure |
| 1313 |
*/ |
| 1314 |
bool setDate(const QString &key, const QDateTime &val); |
| 1315 |
|
| 1316 |
/** |
| 1317 |
The date of the creation of the document |
| 1318 |
*/ |
| 1319 |
QDateTime creationDate() const; |
| 1320 |
|
| 1321 |
/** |
| 1322 |
Set the creation date of the document to \param val |
| 1323 |
|
| 1324 |
\returns true on success, false on failure |
| 1325 |
*/ |
| 1326 |
bool setCreationDate(const QDateTime &val); |
| 1327 |
|
| 1328 |
/** |
| 1329 |
The date of the last change in the document |
| 1330 |
*/ |
| 1331 |
QDateTime modificationDate() const; |
| 1332 |
|
| 1333 |
/** |
| 1334 |
Set the modification date of the document to \param val |
| 1335 |
|
| 1336 |
\returns true on success, false on failure |
| 1337 |
*/ |
| 1338 |
bool setModificationDate(const QDateTime &val); |
| 1339 |
|
| 1340 |
/** |
| 1341 |
Get specified information associated with the document |
| 1342 |
|
| 1343 |
You would use this method with something like: |
| 1344 |
\code |
| 1345 |
QString title = m_doc->info("Title"); |
| 1346 |
QString subject = m_doc->info("Subject"); |
| 1347 |
\endcode |
| 1348 |
|
| 1349 |
In addition to \c Title and \c Subject, other information that may |
| 1350 |
be available include \c Author, \c Keywords, \c Creator and \c Producer. |
| 1351 |
|
| 1352 |
\param type the information that is required |
| 1353 |
|
| 1354 |
\sa infoKeys() to get a list of the available keys |
| 1355 |
*/ |
| 1356 |
QString info(const QString &type) const; |
| 1357 |
|
| 1358 |
/** |
| 1359 |
Set the value of the document's Info dictionary entry specified by \param key to \param val |
| 1360 |
|
| 1361 |
\returns true on success, false on failure |
| 1362 |
*/ |
| 1363 |
bool setInfo(const QString &key, const QString &val); |
| 1364 |
|
| 1365 |
/** |
| 1366 |
The title of the document |
| 1367 |
*/ |
| 1368 |
QString title() const; |
| 1369 |
|
| 1370 |
/** |
| 1371 |
Set the title of the document to \param val |
| 1372 |
|
| 1373 |
\returns true on success, false on failure |
| 1374 |
*/ |
| 1375 |
bool setTitle(const QString &val); |
| 1376 |
|
| 1377 |
/** |
| 1378 |
The author of the document |
| 1379 |
*/ |
| 1380 |
QString author() const; |
| 1381 |
|
| 1382 |
/** |
| 1383 |
Set the author of the document to \param val |
| 1384 |
|
| 1385 |
\returns true on success, false on failure |
| 1386 |
*/ |
| 1387 |
bool setAuthor(const QString &val); |
| 1388 |
|
| 1389 |
/** |
| 1390 |
The subject of the document |
| 1391 |
*/ |
| 1392 |
QString subject() const; |
| 1393 |
|
| 1394 |
/** |
| 1395 |
Set the subject of the document to \param val |
| 1396 |
|
| 1397 |
\returns true on success, false on failure |
| 1398 |
*/ |
| 1399 |
bool setSubject(const QString &val); |
| 1400 |
|
| 1401 |
/** |
| 1402 |
The keywords of the document |
| 1403 |
*/ |
| 1404 |
QString keywords() const; |
| 1405 |
|
| 1406 |
/** |
| 1407 |
Set the keywords of the document to \param val |
| 1408 |
|
| 1409 |
\returns true on success, false on failure |
| 1410 |
*/ |
| 1411 |
bool setKeywords(const QString &val); |
| 1412 |
|
| 1413 |
/** |
| 1414 |
The creator of the document |
| 1415 |
*/ |
| 1416 |
QString creator() const; |
| 1417 |
|
| 1418 |
/** |
| 1419 |
Set the creator of the document to \param val |
| 1420 |
|
| 1421 |
\returns true on success, false on failure |
| 1422 |
*/ |
| 1423 |
bool setCreator(const QString &val); |
| 1424 |
|
| 1425 |
/** |
| 1426 |
The producer of the document |
| 1427 |
*/ |
| 1428 |
QString producer() const; |
| 1429 |
|
| 1430 |
/** |
| 1431 |
Set the producer of the document to \param val |
| 1432 |
|
| 1433 |
\returns true on success, false on failure |
| 1434 |
*/ |
| 1435 |
bool setProducer(const QString &val); |
| 1436 |
|
| 1437 |
/** |
| 1438 |
Remove the document's Info dictionary |
| 1439 |
|
| 1440 |
\returns true on success, false on failure |
| 1441 |
*/ |
| 1442 |
bool removeInfo(); |
| 1443 |
|
| 1444 |
/** |
| 1445 |
Obtain a list of the available string information keys. |
| 1446 |
*/ |
| 1447 |
QStringList infoKeys() const; |
| 1448 |
|
| 1449 |
/** |
| 1450 |
Test if the document is encrypted |
| 1451 |
*/ |
| 1452 |
bool isEncrypted() const; |
| 1453 |
|
| 1454 |
/** |
| 1455 |
Test if the document is linearised |
| 1456 |
|
| 1457 |
In some cases, this is called "fast web view", since it |
| 1458 |
is mostly an optimisation for viewing over the Web. |
| 1459 |
*/ |
| 1460 |
bool isLinearized() const; |
| 1461 |
|
| 1462 |
/** |
| 1463 |
Test if the permissions on the document allow it to be |
| 1464 |
printed |
| 1465 |
*/ |
| 1466 |
bool okToPrint() const; |
| 1467 |
|
| 1468 |
/** |
| 1469 |
Test if the permissions on the document allow it to be |
| 1470 |
printed at high resolution |
| 1471 |
*/ |
| 1472 |
bool okToPrintHighRes() const; |
| 1473 |
|
| 1474 |
/** |
| 1475 |
Test if the permissions on the document allow it to be |
| 1476 |
changed. |
| 1477 |
|
| 1478 |
\note depending on the type of change, it may be more |
| 1479 |
appropriate to check other properties as well. |
| 1480 |
*/ |
| 1481 |
bool okToChange() const; |
| 1482 |
|
| 1483 |
/** |
| 1484 |
Test if the permissions on the document allow the |
| 1485 |
contents to be copied / extracted |
| 1486 |
*/ |
| 1487 |
bool okToCopy() const; |
| 1488 |
|
| 1489 |
/** |
| 1490 |
Test if the permissions on the document allow annotations |
| 1491 |
to be added or modified, and interactive form fields (including |
| 1492 |
signature fields) to be completed. |
| 1493 |
*/ |
| 1494 |
bool okToAddNotes() const; |
| 1495 |
|
| 1496 |
/** |
| 1497 |
Test if the permissions on the document allow interactive |
| 1498 |
form fields (including signature fields) to be completed. |
| 1499 |
|
| 1500 |
\note this can be true even if okToAddNotes() is false - this |
| 1501 |
means that only form completion is permitted. |
| 1502 |
*/ |
| 1503 |
bool okToFillForm() const; |
| 1504 |
|
| 1505 |
/** |
| 1506 |
Test if the permissions on the document allow interactive |
| 1507 |
form fields (including signature fields) to be set, created and |
| 1508 |
modified |
| 1509 |
*/ |
| 1510 |
bool okToCreateFormFields() const; |
| 1511 |
|
| 1512 |
/** |
| 1513 |
Test if the permissions on the document allow content extraction |
| 1514 |
(text and perhaps other content) for accessibility usage (eg for |
| 1515 |
a screen reader) |
| 1516 |
*/ |
| 1517 |
bool okToExtractForAccessibility() const; |
| 1518 |
|
| 1519 |
/** |
| 1520 |
Test if the permissions on the document allow it to be |
| 1521 |
"assembled" - insertion, rotation and deletion of pages; |
| 1522 |
or creation of bookmarks and thumbnail images. |
| 1523 |
|
| 1524 |
\note this can be true even if okToChange() is false |
| 1525 |
*/ |
| 1526 |
bool okToAssemble() const; |
| 1527 |
|
| 1528 |
/** \brief The version specification of a pdf file */ |
| 1529 |
struct PdfVersion |
| 1530 |
{ |
| 1531 |
int major; |
| 1532 |
int minor; |
| 1533 |
}; |
| 1534 |
|
| 1535 |
/** |
| 1536 |
The version of the PDF specification that the document |
| 1537 |
conforms to |
| 1538 |
|
| 1539 |
\since 21.08 |
| 1540 |
*/ |
| 1541 |
PdfVersion getPdfVersion() const; |
| 1542 |
|
| 1543 |
/** |
| 1544 |
The fonts within the PDF document. |
| 1545 |
|
| 1546 |
This is a shorthand for getting all the fonts at once. |
| 1547 |
|
| 1548 |
\note this can take a very long time to run with a large |
| 1549 |
document. You may wish to use a FontIterator if you have more |
| 1550 |
than say 20 pages |
| 1551 |
|
| 1552 |
\see newFontIterator() |
| 1553 |
*/ |
| 1554 |
QList<FontInfo> fonts() const; |
| 1555 |
|
| 1556 |
/** |
| 1557 |
Creates a new FontIterator object for font scanning. |
| 1558 |
|
| 1559 |
The new iterator can be used for reading the font information of the |
| 1560 |
document, reading page by page. |
| 1561 |
|
| 1562 |
\param startPage the initial page from which start reading fonts |
| 1563 |
|
| 1564 |
\see fonts() |
| 1565 |
*/ |
| 1566 |
std::unique_ptr<FontIterator> newFontIterator(int startPage = 0) const; |
| 1567 |
|
| 1568 |
/** |
| 1569 |
The font data if the font is an embedded one. |
| 1570 |
*/ |
| 1571 |
QByteArray fontData(const FontInfo &fi) const; |
| 1572 |
|
| 1573 |
/** |
| 1574 |
The documents embedded within the PDF document. |
| 1575 |
|
| 1576 |
\note there are two types of embedded document - this call |
| 1577 |
only accesses documents that are embedded at the document level. |
| 1578 |
|
| 1579 |
\note The ownership of the EmbeddedFile objects remain with the callee. |
| 1580 |
*/ |
| 1581 |
QList<EmbeddedFile *> embeddedFiles() const; |
| 1582 |
|
| 1583 |
/** |
| 1584 |
Whether there are any documents embedded in this PDF document. |
| 1585 |
*/ |
| 1586 |
bool hasEmbeddedFiles() const; |
| 1587 |
|
| 1588 |
/** |
| 1589 |
Gets the outline of the document |
| 1590 |
|
| 1591 |
\returns a vector of outline items, empty if there are none |
| 1592 |
**/ |
| 1593 |
QVector<OutlineItem> outline() const; |
| 1594 |
|
| 1595 |
/** |
| 1596 |
Tries to resolve the named destination \p name. |
| 1597 |
|
| 1598 |
\note this operation starts a search through the whole document |
| 1599 |
|
| 1600 |
\returns a new LinkDestination object if the named destination was |
| 1601 |
actually found, or empty unique pointer otherwise |
| 1602 |
*/ |
| 1603 |
std::unique_ptr<LinkDestination> linkDestination(const QString &name); |
| 1604 |
|
| 1605 |
/** |
| 1606 |
Sets the paper color |
| 1607 |
|
| 1608 |
\param color the new paper color |
| 1609 |
*/ |
| 1610 |
void setPaperColor(const QColor &color); |
| 1611 |
/** |
| 1612 |
The paper color |
| 1613 |
|
| 1614 |
The default color is white. |
| 1615 |
*/ |
| 1616 |
QColor paperColor() const; |
| 1617 |
|
| 1618 |
/** |
| 1619 |
Sets the backend used to render the pages. |
| 1620 |
|
| 1621 |
\param backend the new rendering backend |
| 1622 |
*/ |
| 1623 |
void setRenderBackend(RenderBackend backend); |
| 1624 |
/** |
| 1625 |
The currently set render backend |
| 1626 |
|
| 1627 |
The default backend is \ref SplashBackend |
| 1628 |
*/ |
| 1629 |
RenderBackend renderBackend() const; |
| 1630 |
|
| 1631 |
/** |
| 1632 |
The available rendering backends. |
| 1633 |
*/ |
| 1634 |
static QSet<RenderBackend> availableRenderBackends(); |
| 1635 |
|
| 1636 |
/** |
| 1637 |
Sets the render \p hint . |
| 1638 |
|
| 1639 |
\note some hints may not be supported by some rendering backends. |
| 1640 |
|
| 1641 |
\param on whether the flag should be added or removed. |
| 1642 |
*/ |
| 1643 |
void setRenderHint(RenderHint hint, bool on = true); |
| 1644 |
/** |
| 1645 |
The currently set render hints. |
| 1646 |
*/ |
| 1647 |
RenderHints renderHints() const; |
| 1648 |
|
| 1649 |
/** |
| 1650 |
Gets a new PS converter for this document. |
| 1651 |
*/ |
| 1652 |
std::unique_ptr<PSConverter> psConverter() const; |
| 1653 |
|
| 1654 |
/** |
| 1655 |
Gets a new PDF converter for this document. |
| 1656 |
*/ |
| 1657 |
std::unique_ptr<PDFConverter> pdfConverter() const; |
| 1658 |
|
| 1659 |
/** |
| 1660 |
Gets the metadata stream contents |
| 1661 |
*/ |
| 1662 |
QString metadata() const; |
| 1663 |
|
| 1664 |
/** |
| 1665 |
Test whether this document has "optional content". |
| 1666 |
|
| 1667 |
Optional content is used to optionally turn on (display) |
| 1668 |
and turn off (not display) some elements of the document. |
| 1669 |
The most common use of this is for layers in design |
| 1670 |
applications, but it can be used for a range of things, |
| 1671 |
such as not including some content in printing, and |
| 1672 |
displaying content in the appropriate language. |
| 1673 |
*/ |
| 1674 |
bool hasOptionalContent() const; |
| 1675 |
|
| 1676 |
/** |
| 1677 |
Itemviews model for optional content. |
| 1678 |
|
| 1679 |
The model is owned by the document. |
| 1680 |
*/ |
| 1681 |
OptContentModel *optionalContentModel(); |
| 1682 |
|
| 1683 |
/** |
| 1684 |
Resets the form with the details contained in the \p link. |
| 1685 |
|
| 1686 |
\since 24.07 |
| 1687 |
*/ |
| 1688 |
void applyResetFormsLink(const LinkResetForm &link); |
| 1689 |
|
| 1690 |
/** |
| 1691 |
Document-level JavaScript scripts. |
| 1692 |
|
| 1693 |
Returns the list of document level JavaScript scripts to be always |
| 1694 |
executed before any other script. |
| 1695 |
*/ |
| 1696 |
QStringList scripts() const; |
| 1697 |
|
| 1698 |
/** |
| 1699 |
Describes the flags for additional document actions i.e. |
| 1700 |
for executing document scripts at different events. |
| 1701 |
This flag is used by additionalAction method to return the |
| 1702 |
particular Link. |
| 1703 |
|
| 1704 |
\since 24.07 |
| 1705 |
*/ |
| 1706 |
enum DocumentAdditionalActionsType |
| 1707 |
{ |
| 1708 |
CloseDocument, ///< Performed before closing the document |
| 1709 |
SaveDocumentStart, ///< Performed before saving the document |
| 1710 |
SaveDocumentFinish, ///< Performed after saving the document |
| 1711 |
PrintDocumentStart, ///< Performed before printing the document |
| 1712 |
PrintDocumentFinish, ///< Performed after printing the document |
| 1713 |
}; |
| 1714 |
|
| 1715 |
/** |
| 1716 |
Returns the additional action of the given @p type for the document or |
| 1717 |
@c 0 if no action has been defined. |
| 1718 |
|
| 1719 |
\since 24.07 |
| 1720 |
*/ |
| 1721 |
std::unique_ptr<Link> additionalAction(DocumentAdditionalActionsType type) const; |
| 1722 |
|
| 1723 |
/** |
| 1724 |
The PDF identifiers. |
| 1725 |
|
| 1726 |
\param permanentId an optional pointer to a variable where store the |
| 1727 |
permanent ID of the document |
| 1728 |
\param updateId an optional pointer to a variable where store the |
| 1729 |
update ID of the document |
| 1730 |
|
| 1731 |
\return whether the document has the IDs |
| 1732 |
*/ |
| 1733 |
bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; |
| 1734 |
|
| 1735 |
/** |
| 1736 |
Returns the type of forms contained in the document |
| 1737 |
*/ |
| 1738 |
FormType formType() const; |
| 1739 |
|
| 1740 |
/** |
| 1741 |
Returns the calculate order for forms (using their id) |
| 1742 |
*/ |
| 1743 |
QVector<int> formCalculateOrder() const; |
| 1744 |
|
| 1745 |
/** |
| 1746 |
Returns the signatures of this document. |
| 1747 |
|
| 1748 |
Prefer to use this over getting the signatures for all the pages of the document |
| 1749 |
since there are documents with signatures that don't belong to a given page |
| 1750 |
*/ |
| 1751 |
std::vector<std::unique_ptr<FormFieldSignature>> signatures() const; |
| 1752 |
|
| 1753 |
/** |
| 1754 |
Returns whether the document's XRef table has been reconstructed or not |
| 1755 |
|
| 1756 |
\since 21.06 |
| 1757 |
*/ |
| 1758 |
bool xrefWasReconstructed() const; |
| 1759 |
|
| 1760 |
/** |
| 1761 |
Sets the document's XRef reconstruction callback, so whenever a XRef table |
| 1762 |
reconstruction happens the callback will get triggered. |
| 1763 |
|
| 1764 |
\since 21.06 |
| 1765 |
*/ |
| 1766 |
void setXRefReconstructedCallback(const std::function<void()> &callback); |
| 1767 |
|
| 1768 |
/** |
| 1769 |
Destructor. |
| 1770 |
*/ |
| 1771 |
~Document(); |
| 1772 |
|
| 1773 |
private: |
| 1774 |
Q_DISABLE_COPY(Document) |
| 1775 |
|
| 1776 |
DocumentData *m_doc; |
| 1777 |
|
| 1778 |
explicit Document(DocumentData *dataA); |
| 1779 |
}; |
| 1780 |
|
| 1781 |
/** |
| 1782 |
Conversion from PDF date string format to QDateTime |
| 1783 |
*/ |
| 1784 |
POPPLER_QT6_EXPORT QDateTime convertDate(const char *dateString); |
| 1785 |
|
| 1786 |
/** |
| 1787 |
Whether the color management functions are available. |
| 1788 |
*/ |
| 1789 |
POPPLER_QT6_EXPORT bool isCmsAvailable(); |
| 1790 |
|
| 1791 |
/** |
| 1792 |
Whether the overprint preview functionality is available. |
| 1793 |
*/ |
| 1794 |
POPPLER_QT6_EXPORT bool isOverprintPreviewAvailable(); |
| 1795 |
|
| 1796 |
class SoundData; |
| 1797 |
/** |
| 1798 |
Container class for a sound file in a PDF document. |
| 1799 |
|
| 1800 |
A sound can be either External (in that case should be loaded the file |
| 1801 |
whose url is represented by url() ), or Embedded, and the player has to |
| 1802 |
play the data contained in data(). |
| 1803 |
*/ |
| 1804 |
class POPPLER_QT6_EXPORT SoundObject |
| 1805 |
{ |
| 1806 |
public: |
| 1807 |
/** |
| 1808 |
The type of sound |
| 1809 |
*/ |
| 1810 |
enum SoundType |
| 1811 |
{ |
| 1812 |
External, ///< The real sound file is external |
| 1813 |
Embedded ///< The sound is contained in the data |
| 1814 |
}; |
| 1815 |
|
| 1816 |
/** |
| 1817 |
The encoding format used for the sound |
| 1818 |
*/ |
| 1819 |
enum SoundEncoding |
| 1820 |
{ |
| 1821 |
Raw, ///< Raw encoding, with unspecified or unsigned values in the range [ 0, 2^B - 1 ] |
| 1822 |
Signed, ///< Twos-complement values |
| 1823 |
muLaw, ///< mu-law-encoded samples |
| 1824 |
ALaw ///< A-law-encoded samples |
| 1825 |
}; |
| 1826 |
|
| 1827 |
/** \cond PRIVATE |
| 1828 |
The caller keeps the ownership of the popplersound argument |
| 1829 |
*/ |
| 1830 |
explicit SoundObject(Sound *popplersound); |
| 1831 |
/// \endcond |
| 1832 |
|
| 1833 |
~SoundObject(); |
| 1834 |
|
| 1835 |
/** |
| 1836 |
Is the sound embedded (SoundObject::Embedded) or external (SoundObject::External)? |
| 1837 |
*/ |
| 1838 |
SoundType soundType() const; |
| 1839 |
|
| 1840 |
/** |
| 1841 |
The URL of the sound file to be played, in case of SoundObject::External |
| 1842 |
*/ |
| 1843 |
QString url() const; |
| 1844 |
|
| 1845 |
/** |
| 1846 |
The data of the sound, in case of SoundObject::Embedded |
| 1847 |
*/ |
| 1848 |
QByteArray data() const; |
| 1849 |
|
| 1850 |
/** |
| 1851 |
The sampling rate of the sound |
| 1852 |
*/ |
| 1853 |
double samplingRate() const; |
| 1854 |
|
| 1855 |
/** |
| 1856 |
The number of sound channels to use to play the sound |
| 1857 |
*/ |
| 1858 |
int channels() const; |
| 1859 |
|
| 1860 |
/** |
| 1861 |
The number of bits per sample value per channel |
| 1862 |
*/ |
| 1863 |
int bitsPerSample() const; |
| 1864 |
|
| 1865 |
/** |
| 1866 |
The encoding used for the sound |
| 1867 |
*/ |
| 1868 |
SoundEncoding soundEncoding() const; |
| 1869 |
|
| 1870 |
private: |
| 1871 |
Q_DISABLE_COPY(SoundObject) |
| 1872 |
|
| 1873 |
SoundData *m_soundData; |
| 1874 |
}; |
| 1875 |
|
| 1876 |
class MovieData; |
| 1877 |
/** |
| 1878 |
Container class for a movie object in a PDF document. |
| 1879 |
*/ |
| 1880 |
class POPPLER_QT6_EXPORT MovieObject |
| 1881 |
{ |
| 1882 |
friend class AnnotationPrivate; |
| 1883 |
|
| 1884 |
public: |
| 1885 |
/** |
| 1886 |
The play mode for playing the movie |
| 1887 |
*/ |
| 1888 |
enum PlayMode |
| 1889 |
{ |
| 1890 |
PlayOnce, ///< Play the movie once, closing the movie controls at the end |
| 1891 |
PlayOpen, ///< Like PlayOnce, but leaving the controls open |
| 1892 |
PlayRepeat, ///< Play continuously until stopped |
| 1893 |
PlayPalindrome ///< Play forward, then backward, then again foward and so on until stopped |
| 1894 |
}; |
| 1895 |
|
| 1896 |
~MovieObject(); |
| 1897 |
|
| 1898 |
/** |
| 1899 |
The URL of the movie to be played |
| 1900 |
*/ |
| 1901 |
QString url() const; |
| 1902 |
|
| 1903 |
/** |
| 1904 |
The size of the movie |
| 1905 |
*/ |
| 1906 |
QSize size() const; |
| 1907 |
|
| 1908 |
/** |
| 1909 |
The rotation (either 0, 90, 180, or 270 degrees clockwise) for the movie, |
| 1910 |
*/ |
| 1911 |
int rotation() const; |
| 1912 |
|
| 1913 |
/** |
| 1914 |
Whether show a bar with movie controls |
| 1915 |
*/ |
| 1916 |
bool showControls() const; |
| 1917 |
|
| 1918 |
/** |
| 1919 |
How to play the movie |
| 1920 |
*/ |
| 1921 |
PlayMode playMode() const; |
| 1922 |
|
| 1923 |
/** |
| 1924 |
Returns whether a poster image should be shown if the movie is not playing. |
| 1925 |
*/ |
| 1926 |
bool showPosterImage() const; |
| 1927 |
|
| 1928 |
/** |
| 1929 |
Returns the poster image that should be shown if the movie is not playing. |
| 1930 |
If the image is null but showImagePoster() returns @c true, the first frame of the movie |
| 1931 |
should be used as poster image. |
| 1932 |
*/ |
| 1933 |
QImage posterImage() const; |
| 1934 |
|
| 1935 |
private: |
| 1936 |
/// \cond PRIVATE |
| 1937 |
explicit MovieObject(AnnotMovie *ann); |
| 1938 |
/// \endcond |
| 1939 |
|
| 1940 |
Q_DISABLE_COPY(MovieObject) |
| 1941 |
|
| 1942 |
MovieData *m_movieData; |
| 1943 |
}; |
| 1944 |
|
| 1945 |
} |
| 1946 |
|
| 1947 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags) |
| 1948 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::SearchFlags) |
| 1949 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints) |
| 1950 |
|
| 1951 |
#endif |