| 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 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, g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]> |
| 35 |
* Copyright (C) 2025 Stefan Brüns <[email protected]> |
| 36 |
* |
| 37 |
* This program is free software; you can redistribute it and/or modify |
| 38 |
* it under the terms of the GNU General Public License as published by |
| 39 |
* the Free Software Foundation; either version 2, or (at your option) |
| 40 |
* any later version. |
| 41 |
* |
| 42 |
* This program is distributed in the hope that it will be useful, |
| 43 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 44 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 45 |
* GNU General Public License for more details. |
| 46 |
* |
| 47 |
* You should have received a copy of the GNU General Public License |
| 48 |
* along with this program; if not, write to the Free Software |
| 49 |
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| 50 |
*/ |
| 51 |
|
| 52 |
#ifndef __POPPLER_QT_H__ |
| 53 |
#define __POPPLER_QT_H__ |
| 54 |
|
| 55 |
#include <functional> |
| 56 |
|
| 57 |
#include "poppler-annotation.h" |
| 58 |
#include "poppler-link.h" |
| 59 |
#include "poppler-optcontent.h" |
| 60 |
#include "poppler-page-transition.h" |
| 61 |
|
| 62 |
#include <QtCore/QByteArray> |
| 63 |
#include <QtCore/QDateTime> |
| 64 |
#include <QtCore/QSet> |
| 65 |
#include <QtXml/QDomDocument> |
| 66 |
#include "poppler-export.h" |
| 67 |
|
| 68 |
class EmbFile; |
| 69 |
class Sound; |
| 70 |
class AnnotMovie; |
| 71 |
|
| 72 |
/** |
| 73 |
The %Poppler Qt5 binding. |
| 74 |
*/ |
| 75 |
namespace Poppler { |
| 76 |
|
| 77 |
class Document; |
| 78 |
class DocumentData; |
| 79 |
|
| 80 |
class PageData; |
| 81 |
|
| 82 |
class FormField; |
| 83 |
class FormFieldSignature; |
| 84 |
|
| 85 |
class TextBoxData; |
| 86 |
|
| 87 |
class PDFConverter; |
| 88 |
class PSConverter; |
| 89 |
|
| 90 |
struct OutlineItemData; |
| 91 |
|
| 92 |
/** |
| 93 |
Debug/error function. |
| 94 |
|
| 95 |
This function type is used for debugging & error output; |
| 96 |
the first parameter is the actual message, the second is the unaltered |
| 97 |
closure argument which was passed to the setDebugErrorFunction call. |
| 98 |
|
| 99 |
\since 0.16 |
| 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 |
\since 0.16 |
| 113 |
*/ |
| 114 |
POPPLER_QT5_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure); |
| 115 |
|
| 116 |
/** |
| 117 |
* The various types of error strings. |
| 118 |
* |
| 119 |
* \since 25.07 |
| 120 |
*/ |
| 121 |
enum class ErrorStringType |
| 122 |
{ |
| 123 |
/**The string should be treated like a error code. It could be a hex code, a position in the poppler sources or something similar*/ |
| 124 |
ErrorCodeString, |
| 125 |
/**The string should be treated as an advanced error message that can be shown to user */ |
| 126 |
UserString |
| 127 |
}; |
| 128 |
|
| 129 |
/** |
| 130 |
* Combination of an error data and type of error string |
| 131 |
* |
| 132 |
* \since 25.07 |
| 133 |
*/ |
| 134 |
struct ErrorString |
| 135 |
{ |
| 136 |
QVariant data; |
| 137 |
ErrorStringType type; |
| 138 |
}; |
| 139 |
|
| 140 |
/** |
| 141 |
Describes the physical location of text on a document page |
| 142 |
|
| 143 |
This very simple class describes the physical location of text |
| 144 |
on the page. It consists of |
| 145 |
- a QString that contains the text |
| 146 |
- a QRectF that gives a box that describes where on the page |
| 147 |
the text is found. |
| 148 |
*/ |
| 149 |
class POPPLER_QT5_EXPORT TextBox |
| 150 |
{ |
| 151 |
friend class Page; |
| 152 |
|
| 153 |
public: |
| 154 |
/** |
| 155 |
The default constructor sets the \p text and the rectangle that |
| 156 |
contains the text. Coordinates for the \p bBox are in points = |
| 157 |
1/72 of an inch. |
| 158 |
*/ |
| 159 |
TextBox(const QString &text, const QRectF &bBox); |
| 160 |
/** |
| 161 |
Destructor. |
| 162 |
*/ |
| 163 |
~TextBox(); |
| 164 |
|
| 165 |
/** |
| 166 |
Returns the text of this text box |
| 167 |
*/ |
| 168 |
QString text() const; |
| 169 |
|
| 170 |
/** |
| 171 |
Returns the position of the text, in point, i.e., 1/72 of |
| 172 |
an inch |
| 173 |
|
| 174 |
\since 0.8 |
| 175 |
*/ |
| 176 |
QRectF boundingBox() const; |
| 177 |
|
| 178 |
/** |
| 179 |
Returns the pointer to the next text box, if there is one. |
| 180 |
|
| 181 |
Otherwise, it returns a null pointer. |
| 182 |
*/ |
| 183 |
TextBox *nextWord() const; |
| 184 |
|
| 185 |
/** |
| 186 |
Returns the bounding box of the \p i -th characted of the word. |
| 187 |
*/ |
| 188 |
QRectF charBoundingBox(int i) const; |
| 189 |
|
| 190 |
/** |
| 191 |
Returns whether there is a space character after this text box |
| 192 |
*/ |
| 193 |
bool hasSpaceAfter() const; |
| 194 |
|
| 195 |
private: |
| 196 |
Q_DISABLE_COPY(TextBox) |
| 197 |
|
| 198 |
TextBoxData *m_data; |
| 199 |
}; |
| 200 |
|
| 201 |
class FontInfoData; |
| 202 |
/** |
| 203 |
Container class for information about a font within a PDF |
| 204 |
document |
| 205 |
*/ |
| 206 |
class POPPLER_QT5_EXPORT FontInfo |
| 207 |
{ |
| 208 |
friend class Document; |
| 209 |
|
| 210 |
public: |
| 211 |
/** |
| 212 |
The type of font. |
| 213 |
*/ |
| 214 |
enum Type |
| 215 |
{ |
| 216 |
unknown, |
| 217 |
Type1, |
| 218 |
Type1C, |
| 219 |
Type1COT, |
| 220 |
Type3, |
| 221 |
TrueType, |
| 222 |
TrueTypeOT, |
| 223 |
CIDType0, |
| 224 |
CIDType0C, |
| 225 |
CIDType0COT, |
| 226 |
CIDTrueType, |
| 227 |
CIDTrueTypeOT |
| 228 |
}; |
| 229 |
|
| 230 |
/// \cond PRIVATE |
| 231 |
/** |
| 232 |
Create a new font information container. |
| 233 |
*/ |
| 234 |
FontInfo(); |
| 235 |
|
| 236 |
/** |
| 237 |
Create a new font information container. |
| 238 |
*/ |
| 239 |
explicit FontInfo(const FontInfoData &fid); |
| 240 |
/// \endcond |
| 241 |
|
| 242 |
/** |
| 243 |
Copy constructor. |
| 244 |
*/ |
| 245 |
FontInfo(const FontInfo &fi); |
| 246 |
|
| 247 |
/** |
| 248 |
Destructor. |
| 249 |
*/ |
| 250 |
~FontInfo(); |
| 251 |
|
| 252 |
/** |
| 253 |
The name of the font. Can be a null QString if the font has no name |
| 254 |
*/ |
| 255 |
QString name() const; |
| 256 |
|
| 257 |
/** |
| 258 |
The name of the substitute font. Can be a null QString if the font has no substitute font |
| 259 |
@since 0.80 |
| 260 |
*/ |
| 261 |
QString substituteName() const; |
| 262 |
|
| 263 |
/** |
| 264 |
The path of the font file used to represent this font on this system, |
| 265 |
or a null string is the font is embedded |
| 266 |
*/ |
| 267 |
QString file() const; |
| 268 |
|
| 269 |
/** |
| 270 |
Whether the font is embedded in the file, or not |
| 271 |
|
| 272 |
\return true if the font is embedded |
| 273 |
*/ |
| 274 |
bool isEmbedded() const; |
| 275 |
|
| 276 |
/** |
| 277 |
Whether the font provided is only a subset of the full |
| 278 |
font or not. This only has meaning if the font is embedded. |
| 279 |
|
| 280 |
\return true if the font is only a subset |
| 281 |
*/ |
| 282 |
bool isSubset() const; |
| 283 |
|
| 284 |
/** |
| 285 |
The type of font encoding |
| 286 |
|
| 287 |
\return a enumerated value corresponding to the font encoding used |
| 288 |
|
| 289 |
\sa typeName for a string equivalent |
| 290 |
*/ |
| 291 |
Type type() const; |
| 292 |
|
| 293 |
/** |
| 294 |
The name of the font encoding used |
| 295 |
|
| 296 |
\note if you are looking for the name of the font (as opposed to the |
| 297 |
encoding format used), you probably want name(). |
| 298 |
|
| 299 |
\sa type for a enumeration version |
| 300 |
*/ |
| 301 |
QString typeName() const; |
| 302 |
|
| 303 |
/** |
| 304 |
Standard assignment operator |
| 305 |
*/ |
| 306 |
FontInfo &operator=(const FontInfo &fi); |
| 307 |
|
| 308 |
private: |
| 309 |
FontInfoData *m_data; |
| 310 |
}; |
| 311 |
|
| 312 |
class FontIteratorData; |
| 313 |
/** |
| 314 |
Iterator for reading the fonts in a document. |
| 315 |
|
| 316 |
FontIterator provides a Java-style iterator for reading the fonts in a |
| 317 |
document. |
| 318 |
|
| 319 |
You can use it in the following way: |
| 320 |
\code |
| 321 |
Poppler::FontIterator* it = doc->newFontIterator(); |
| 322 |
while (it->hasNext()) { |
| 323 |
QList<Poppler::FontInfo> fonts = it->next(); |
| 324 |
// do something with the fonts |
| 325 |
} |
| 326 |
// after doing the job, the iterator must be freed |
| 327 |
delete it; |
| 328 |
\endcode |
| 329 |
|
| 330 |
\since 0.12 |
| 331 |
*/ |
| 332 |
class POPPLER_QT5_EXPORT FontIterator |
| 333 |
{ |
| 334 |
friend class Document; |
| 335 |
friend class DocumentData; |
| 336 |
|
| 337 |
public: |
| 338 |
/** |
| 339 |
Destructor. |
| 340 |
*/ |
| 341 |
~FontIterator(); |
| 342 |
|
| 343 |
/** |
| 344 |
Returns the fonts of the current page and then advances the iterator |
| 345 |
to the next page. |
| 346 |
*/ |
| 347 |
QList<FontInfo> next(); |
| 348 |
|
| 349 |
/** |
| 350 |
Checks whether there is at least one more page to iterate, ie returns |
| 351 |
false when the iterator is beyond the last page. |
| 352 |
*/ |
| 353 |
bool hasNext() const; |
| 354 |
|
| 355 |
/** |
| 356 |
Returns the current page where the iterator is. |
| 357 |
*/ |
| 358 |
int currentPage() const; |
| 359 |
|
| 360 |
private: |
| 361 |
Q_DISABLE_COPY(FontIterator) |
| 362 |
FontIterator(int, DocumentData *dd); |
| 363 |
|
| 364 |
FontIteratorData *d; |
| 365 |
}; |
| 366 |
|
| 367 |
class EmbeddedFileData; |
| 368 |
/** |
| 369 |
Container class for an embedded file with a PDF document |
| 370 |
*/ |
| 371 |
class POPPLER_QT5_EXPORT EmbeddedFile |
| 372 |
{ |
| 373 |
friend class DocumentData; |
| 374 |
friend class AnnotationPrivate; |
| 375 |
|
| 376 |
public: |
| 377 |
/// \cond PRIVATE |
| 378 |
explicit EmbeddedFile(EmbFile *embfile); |
| 379 |
/// \endcond |
| 380 |
|
| 381 |
/** |
| 382 |
Destructor. |
| 383 |
*/ |
| 384 |
~EmbeddedFile(); |
| 385 |
|
| 386 |
/** |
| 387 |
The name associated with the file |
| 388 |
*/ |
| 389 |
QString name() const; |
| 390 |
|
| 391 |
/** |
| 392 |
The description associated with the file, if any. |
| 393 |
|
| 394 |
This will return an empty QString if there is no description element |
| 395 |
*/ |
| 396 |
QString description() const; |
| 397 |
|
| 398 |
/** |
| 399 |
The size of the file. |
| 400 |
|
| 401 |
This will return < 0 if there is no size element |
| 402 |
*/ |
| 403 |
int size() const; |
| 404 |
|
| 405 |
/** |
| 406 |
The modification date for the embedded file, if known. |
| 407 |
*/ |
| 408 |
QDateTime modDate() const; |
| 409 |
|
| 410 |
/** |
| 411 |
The creation date for the embedded file, if known. |
| 412 |
*/ |
| 413 |
QDateTime createDate() const; |
| 414 |
|
| 415 |
/** |
| 416 |
The MD5 checksum of the file. |
| 417 |
|
| 418 |
This will return an empty QByteArray if there is no checksum element. |
| 419 |
*/ |
| 420 |
QByteArray checksum() const; |
| 421 |
|
| 422 |
/** |
| 423 |
The MIME type of the file, if known. |
| 424 |
|
| 425 |
\since 0.8 |
| 426 |
*/ |
| 427 |
QString mimeType() const; |
| 428 |
|
| 429 |
/** |
| 430 |
The data as a byte array |
| 431 |
*/ |
| 432 |
QByteArray data(); |
| 433 |
|
| 434 |
/** |
| 435 |
Is the embedded file valid? |
| 436 |
|
| 437 |
\since 0.12 |
| 438 |
*/ |
| 439 |
bool isValid() const; |
| 440 |
|
| 441 |
/** |
| 442 |
A QDataStream for the actual data? |
| 443 |
*/ |
| 444 |
// QDataStream dataStream() const; |
| 445 |
|
| 446 |
private: |
| 447 |
Q_DISABLE_COPY(EmbeddedFile) |
| 448 |
explicit EmbeddedFile(EmbeddedFileData &dd); |
| 449 |
|
| 450 |
EmbeddedFileData *m_embeddedFile; |
| 451 |
}; |
| 452 |
|
| 453 |
/** |
| 454 |
\brief A page in a document. |
| 455 |
|
| 456 |
The Page class represents a single page within a PDF document. |
| 457 |
|
| 458 |
You cannot construct a Page directly, but you have to use the Document |
| 459 |
functions that return a new Page out of an index or a label. |
| 460 |
*/ |
| 461 |
class POPPLER_QT5_EXPORT Page |
| 462 |
{ |
| 463 |
friend class Document; |
| 464 |
|
| 465 |
public: |
| 466 |
/** |
| 467 |
Destructor. |
| 468 |
*/ |
| 469 |
~Page(); |
| 470 |
|
| 471 |
/** |
| 472 |
The type of rotation to apply for an operation |
| 473 |
*/ |
| 474 |
enum Rotation |
| 475 |
{ |
| 476 |
Rotate0 = 0, ///< Do not rotate |
| 477 |
Rotate90 = 1, ///< Rotate 90 degrees clockwise |
| 478 |
Rotate180 = 2, ///< Rotate 180 degrees |
| 479 |
Rotate270 = 3 ///< Rotate 270 degrees clockwise (90 degrees counterclockwise) |
| 480 |
}; |
| 481 |
|
| 482 |
/** |
| 483 |
The kinds of page actions |
| 484 |
*/ |
| 485 |
enum PageAction |
| 486 |
{ |
| 487 |
Opening, ///< The action when a page is "opened" |
| 488 |
Closing ///< The action when a page is "closed" |
| 489 |
}; |
| 490 |
|
| 491 |
/** |
| 492 |
How the text is going to be returned |
| 493 |
\since 0.16 |
| 494 |
*/ |
| 495 |
enum TextLayout |
| 496 |
{ |
| 497 |
PhysicalLayout, ///< The text is layouted to resemble the real page layout |
| 498 |
RawOrderLayout, ///< The text is returned without any type of processing |
| 499 |
ReadingOrder, ///< The text is returned in reading order, \since 26.01 |
| 500 |
}; |
| 501 |
|
| 502 |
/** |
| 503 |
Additional flags for the renderToPainter method |
| 504 |
\since 0.16 |
| 505 |
*/ |
| 506 |
enum PainterFlag |
| 507 |
{ |
| 508 |
NoPainterFlags = 0x00000000, ///< \since 0.63 |
| 509 |
/** |
| 510 |
Do not save/restore the caller-owned painter. |
| 511 |
|
| 512 |
renderToPainter() by default preserves, using save() + restore(), |
| 513 |
the state of the painter specified; if this is not needed, this |
| 514 |
flag can avoid this job |
| 515 |
*/ |
| 516 |
DontSaveAndRestore = 0x00000001 |
| 517 |
}; |
| 518 |
Q_DECLARE_FLAGS(PainterFlags, PainterFlag) |
| 519 |
|
| 520 |
/** |
| 521 |
Render the page to a QImage using the current |
| 522 |
\link Document::renderBackend() Document renderer\endlink. |
| 523 |
|
| 524 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 525 |
compute the size of the image from the horizontal and vertical |
| 526 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 527 |
method renders only a part of the page, specified by the |
| 528 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned |
| 529 |
QImage then has size (\p w, \p h), independent of the page |
| 530 |
size. |
| 531 |
|
| 532 |
\param x specifies the left x-coordinate of the box, in |
| 533 |
pixels. |
| 534 |
|
| 535 |
\param y specifies the top y-coordinate of the box, in |
| 536 |
pixels. |
| 537 |
|
| 538 |
\param w specifies the width of the box, in pixels. |
| 539 |
|
| 540 |
\param h specifies the height of the box, in pixels. |
| 541 |
|
| 542 |
\param xres horizontal resolution of the graphics device, |
| 543 |
in dots per inch |
| 544 |
|
| 545 |
\param yres vertical resolution of the graphics device, in |
| 546 |
dots per inch |
| 547 |
|
| 548 |
\param rotate how to rotate the page |
| 549 |
|
| 550 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 551 |
well-tested. Unusual or meaningless parameters may lead to |
| 552 |
rather unexpected results. |
| 553 |
|
| 554 |
\returns a QImage of the page, or a null image on failure. |
| 555 |
|
| 556 |
\since 0.6 |
| 557 |
*/ |
| 558 |
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; |
| 559 |
|
| 560 |
/** |
| 561 |
Partial Update renderToImage callback. |
| 562 |
|
| 563 |
This function type is used for doing partial rendering updates; |
| 564 |
the first parameter is the image as rendered up to now, the second is the unaltered |
| 565 |
closure argument which was passed to the renderToImage call. |
| 566 |
|
| 567 |
\since 0.62 |
| 568 |
*/ |
| 569 |
using RenderToImagePartialUpdateFunc = void (*)(const QImage & /*image*/, const QVariant & /*closure*/); |
| 570 |
|
| 571 |
/** |
| 572 |
Partial Update query renderToImage callback. |
| 573 |
|
| 574 |
This function type is used for query if the partial rendering update should happen; |
| 575 |
the parameter is the unaltered closure argument which was passed to the renderToImage call. |
| 576 |
|
| 577 |
\since 0.62 |
| 578 |
*/ |
| 579 |
using ShouldRenderToImagePartialQueryFunc = bool (*)(const QVariant & /*closure*/); |
| 580 |
|
| 581 |
/** |
| 582 |
Render the page to a QImage using the current |
| 583 |
\link Document::renderBackend() Document renderer\endlink. |
| 584 |
|
| 585 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 586 |
compute the size of the image from the horizontal and vertical |
| 587 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 588 |
method renders only a part of the page, specified by the |
| 589 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned |
| 590 |
QImage then has size (\p w, \p h), independent of the page |
| 591 |
size. |
| 592 |
|
| 593 |
\param x specifies the left x-coordinate of the box, in |
| 594 |
pixels. |
| 595 |
|
| 596 |
\param y specifies the top y-coordinate of the box, in |
| 597 |
pixels. |
| 598 |
|
| 599 |
\param w specifies the width of the box, in pixels. |
| 600 |
|
| 601 |
\param h specifies the height of the box, in pixels. |
| 602 |
|
| 603 |
\param xres horizontal resolution of the graphics device, |
| 604 |
in dots per inch |
| 605 |
|
| 606 |
\param yres vertical resolution of the graphics device, in |
| 607 |
dots per inch |
| 608 |
|
| 609 |
\param rotate how to rotate the page |
| 610 |
|
| 611 |
\param partialUpdateCallback callback that will be called to |
| 612 |
report a partial rendering update |
| 613 |
|
| 614 |
\param shouldDoPartialUpdateCallback callback that will be called |
| 615 |
to ask if a partial rendering update is wanted. This exists |
| 616 |
because doing a partial rendering update needs to copy the image |
| 617 |
buffer so if it is not wanted it is better skipped early. |
| 618 |
|
| 619 |
\param payload opaque structure that will be passed |
| 620 |
back to partialUpdateCallback and shouldDoPartialUpdateCallback. |
| 621 |
|
| 622 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 623 |
well-tested. Unusual or meaningless parameters may lead to |
| 624 |
rather unexpected results. |
| 625 |
|
| 626 |
\returns a QImage of the page, or a null image on failure. |
| 627 |
|
| 628 |
\since 0.62 |
| 629 |
*/ |
| 630 |
QImage renderToImage(double xres, double yres, int x, int y, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, |
| 631 |
const QVariant &payload) const; |
| 632 |
|
| 633 |
/** |
| 634 |
Abort query function callback. |
| 635 |
|
| 636 |
This function type is used for query if the current rendering/text extraction should be cancelled. |
| 637 |
|
| 638 |
\since 0.63 |
| 639 |
*/ |
| 640 |
using ShouldAbortQueryFunc = bool (*)(const QVariant & /*closure*/); |
| 641 |
|
| 642 |
/** |
| 643 |
Render the page to a QImage using the current |
| 644 |
\link Document::renderBackend() Document renderer\endlink. |
| 645 |
|
| 646 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 647 |
compute the size of the image from the horizontal and vertical |
| 648 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 649 |
method renders only a part of the page, specified by the |
| 650 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned |
| 651 |
QImage then has size (\p w, \p h), independent of the page |
| 652 |
size. |
| 653 |
|
| 654 |
\param x specifies the left x-coordinate of the box, in |
| 655 |
pixels. |
| 656 |
|
| 657 |
\param y specifies the top y-coordinate of the box, in |
| 658 |
pixels. |
| 659 |
|
| 660 |
\param w specifies the width of the box, in pixels. |
| 661 |
|
| 662 |
\param h specifies the height of the box, in pixels. |
| 663 |
|
| 664 |
\param xres horizontal resolution of the graphics device, |
| 665 |
in dots per inch |
| 666 |
|
| 667 |
\param yres vertical resolution of the graphics device, in |
| 668 |
dots per inch |
| 669 |
|
| 670 |
\param rotate how to rotate the page |
| 671 |
|
| 672 |
\param partialUpdateCallback callback that will be called to |
| 673 |
report a partial rendering update |
| 674 |
|
| 675 |
\param shouldDoPartialUpdateCallback callback that will be called |
| 676 |
to ask if a partial rendering update is wanted. This exists |
| 677 |
because doing a partial rendering update needs to copy the image |
| 678 |
buffer so if it is not wanted it is better skipped early. |
| 679 |
|
| 680 |
\param shouldAbortRenderCallback callback that will be called |
| 681 |
to ask if the rendering should be cancelled. |
| 682 |
|
| 683 |
\param payload opaque structure that will be passed |
| 684 |
back to partialUpdateCallback, shouldDoPartialUpdateCallback |
| 685 |
and shouldAbortRenderCallback. |
| 686 |
|
| 687 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 688 |
well-tested. Unusual or meaningless parameters may lead to |
| 689 |
rather unexpected results. |
| 690 |
|
| 691 |
\returns a QImage of the page, or a null image on failure. |
| 692 |
|
| 693 |
\since 0.63 |
| 694 |
*/ |
| 695 |
QImage renderToImage(double xres, double yres, int x, int y, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, |
| 696 |
ShouldAbortQueryFunc shouldAbortRenderCallback, const QVariant &payload) const; |
| 697 |
|
| 698 |
/** |
| 699 |
Render the page to the specified QPainter using the current |
| 700 |
\link Document::renderBackend() Document renderer\endlink. |
| 701 |
|
| 702 |
If \p x = \p y = \p w = \p h = -1, the method will automatically |
| 703 |
compute the size of the page area from the horizontal and vertical |
| 704 |
resolutions specified in \p xres and \p yres. Otherwise, the |
| 705 |
method renders only a part of the page, specified by the |
| 706 |
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. |
| 707 |
|
| 708 |
\param painter the painter to paint on |
| 709 |
|
| 710 |
\param x specifies the left x-coordinate of the box, in |
| 711 |
pixels. |
| 712 |
|
| 713 |
\param y specifies the top y-coordinate of the box, in |
| 714 |
pixels. |
| 715 |
|
| 716 |
\param w specifies the width of the box, in pixels. |
| 717 |
|
| 718 |
\param h specifies the height of the box, in pixels. |
| 719 |
|
| 720 |
\param xres horizontal resolution of the graphics device, |
| 721 |
in dots per inch |
| 722 |
|
| 723 |
\param yres vertical resolution of the graphics device, in |
| 724 |
dots per inch |
| 725 |
|
| 726 |
\param rotate how to rotate the page |
| 727 |
|
| 728 |
\param flags additional painter flags |
| 729 |
|
| 730 |
\warning The parameter (\p x, \p y, \p w, \p h) are not |
| 731 |
well-tested. Unusual or meaningless parameters may lead to |
| 732 |
rather unexpected results. |
| 733 |
|
| 734 |
\returns whether the painting succeeded |
| 735 |
|
| 736 |
\note This method is only supported for the QPainterOutputDev |
| 737 |
|
| 738 |
\since 0.16 |
| 739 |
*/ |
| 740 |
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; |
| 741 |
|
| 742 |
/** |
| 743 |
Get the page thumbnail if it exists. |
| 744 |
|
| 745 |
\return a QImage of the thumbnail, or a null image |
| 746 |
if the PDF does not contain one for this page |
| 747 |
|
| 748 |
\since 0.12 |
| 749 |
*/ |
| 750 |
QImage thumbnail() const; |
| 751 |
|
| 752 |
/** |
| 753 |
Returns the text that is inside a specified rectangle |
| 754 |
|
| 755 |
\param rect the rectangle specifying the area of interest, |
| 756 |
with coordinates given in points, i.e., 1/72th of an inch. |
| 757 |
If rect is null, all text on the page is given |
| 758 |
|
| 759 |
\param textLayout the layouting that should be applied to the text. |
| 760 |
ReadingOrder is not supported with non null rect |
| 761 |
|
| 762 |
\since 0.16 |
| 763 |
**/ |
| 764 |
QString text(const QRectF &rect, TextLayout textLayout) const; |
| 765 |
|
| 766 |
/** |
| 767 |
Returns the text that is inside a specified rectangle. |
| 768 |
The text is returned using the physical layout of the page |
| 769 |
|
| 770 |
\param rect the rectangle specifying the area of interest, |
| 771 |
with coordinates given in points, i.e., 1/72th of an inch. |
| 772 |
If rect is null, all text on the page is given |
| 773 |
**/ |
| 774 |
QString text(const QRectF &rect) const; |
| 775 |
|
| 776 |
/** |
| 777 |
The starting point for a search |
| 778 |
*/ |
| 779 |
enum SearchDirection |
| 780 |
{ |
| 781 |
FromTop, ///< Start sorting at the top of the document |
| 782 |
NextResult, ///< Find the next result, moving "down the page" |
| 783 |
PreviousResult ///< Find the previous result, moving "up the page" |
| 784 |
}; |
| 785 |
|
| 786 |
/** |
| 787 |
The type of search to perform |
| 788 |
*/ |
| 789 |
enum SearchMode |
| 790 |
{ |
| 791 |
CaseSensitive, ///< Case differences cause no match in searching |
| 792 |
CaseInsensitive ///< Case differences are ignored in matching |
| 793 |
}; |
| 794 |
|
| 795 |
/** |
| 796 |
Flags to modify the search behaviour \since 0.31 |
| 797 |
*/ |
| 798 |
enum SearchFlag |
| 799 |
{ |
| 800 |
NoSearchFlags = 0x00000000, ///< since 0.63 |
| 801 |
IgnoreCase = 0x00000001, ///< Case differences are ignored |
| 802 |
WholeWords = 0x00000002, ///< Only whole words are matched |
| 803 |
IgnoreDiacritics = 0x00000004, ///< Diacritic differences (eg. accents, umlauts, diaeresis) are ignored. \since 0.73 |
| 804 |
///< This option will have no effect if the search term contains characters which |
| 805 |
///< are not pure ascii. |
| 806 |
AcrossLines = 0x00000008 ///< Allows to match on text spanning from end of a line to the next line. |
| 807 |
///< It won't match on text spanning more than two lines. Automatically ignores hyphen |
| 808 |
///< at end of line, and allows whitespace in search term to match on newline. \since 21.05.0 |
| 809 |
}; |
| 810 |
Q_DECLARE_FLAGS(SearchFlags, SearchFlag) |
| 811 |
|
| 812 |
/** |
| 813 |
Returns true if the specified text was found. |
| 814 |
|
| 815 |
\param text the text the search |
| 816 |
\param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult |
| 817 |
indicates where to continue searching for |
| 818 |
\param direction in which direction do the search |
| 819 |
\param caseSensitive be case sensitive? |
| 820 |
\param rotate the rotation to apply for the search order |
| 821 |
\since 0.14 |
| 822 |
**/ |
| 823 |
Q_DECL_DEPRECATED bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; |
| 824 |
|
| 825 |
/** |
| 826 |
Returns true if the specified text was found. |
| 827 |
|
| 828 |
\param text the text the search |
| 829 |
\param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult |
| 830 |
indicates where to continue searching for |
| 831 |
\param direction in which direction do the search |
| 832 |
\param flags the flags to consider during matching |
| 833 |
\param rotate the rotation to apply for the search order |
| 834 |
|
| 835 |
\since 0.31 |
| 836 |
**/ |
| 837 |
bool search(const QString &text, double &sLeft, double &sTop, double &sRight, double &sBottom, SearchDirection direction, SearchFlags flags = NoSearchFlags, Rotation rotate = Rotate0) const; |
| 838 |
|
| 839 |
/** |
| 840 |
Returns a list of all occurrences of the specified text on the page. |
| 841 |
|
| 842 |
\param text the text to search |
| 843 |
\param caseSensitive whether to be case sensitive |
| 844 |
\param rotate the rotation to apply for the search order |
| 845 |
|
| 846 |
\warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. |
| 847 |
|
| 848 |
\since 0.22 |
| 849 |
**/ |
| 850 |
Q_DECL_DEPRECATED QList<QRectF> search(const QString &text, SearchMode caseSensitive, Rotation rotate = Rotate0) const; |
| 851 |
|
| 852 |
/** |
| 853 |
Returns a list of all occurrences of the specified text on the page. |
| 854 |
|
| 855 |
if SearchFlags::AcrossLines is given in \param flags, then rects may just |
| 856 |
be parts of the text itself if it's split between multiple lines. |
| 857 |
|
| 858 |
\param text the text to search |
| 859 |
\param flags the flags to consider during matching |
| 860 |
\param rotate the rotation to apply for the search order |
| 861 |
|
| 862 |
\warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. |
| 863 |
|
| 864 |
\since 0.31 |
| 865 |
**/ |
| 866 |
QList<QRectF> search(const QString &text, SearchFlags flags = NoSearchFlags, Rotation rotate = Rotate0) const; |
| 867 |
|
| 868 |
/** |
| 869 |
Returns a list of text of the page |
| 870 |
|
| 871 |
This method returns a QList of TextBoxes that contain all |
| 872 |
the text of the page, with roughly one text word of text |
| 873 |
per TextBox item. |
| 874 |
|
| 875 |
For text written in western languages (left-to-right and |
| 876 |
up-to-down), the QList contains the text in the proper |
| 877 |
order. |
| 878 |
|
| 879 |
\note The caller owns the text boxes and they should |
| 880 |
be deleted when no longer required. |
| 881 |
|
| 882 |
\warning This method is not tested with Asian scripts |
| 883 |
*/ |
| 884 |
QList<TextBox *> textList(Rotation rotate = Rotate0) const; |
| 885 |
|
| 886 |
/** |
| 887 |
Returns a list of text of the page |
| 888 |
|
| 889 |
This method returns a QList of TextBoxes that contain all |
| 890 |
the text of the page, with roughly one text word of text |
| 891 |
per TextBox item. |
| 892 |
|
| 893 |
For text written in western languages (left-to-right and |
| 894 |
up-to-down), the QList contains the text in the proper |
| 895 |
order. |
| 896 |
|
| 897 |
\param shouldAbortExtractionCallback callback that will be called |
| 898 |
to ask if the text extraction should be cancelled. |
| 899 |
|
| 900 |
\param closure opaque structure that will be passed |
| 901 |
back to shouldAbortExtractionCallback. |
| 902 |
|
| 903 |
\note The caller owns the text boxes and they should |
| 904 |
be deleted when no longer required. |
| 905 |
|
| 906 |
\warning This method is not tested with Asian scripts |
| 907 |
|
| 908 |
// \since 0.63 |
| 909 |
*/ |
| 910 |
QList<TextBox *> textList(Rotation rotate, ShouldAbortQueryFunc shouldAbortExtractionCallback, const QVariant &closure) const; |
| 911 |
|
| 912 |
/** |
| 913 |
\return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) |
| 914 |
*/ |
| 915 |
QSizeF pageSizeF() const; |
| 916 |
|
| 917 |
/** |
| 918 |
\return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) |
| 919 |
*/ |
| 920 |
QSize pageSize() const; |
| 921 |
|
| 922 |
/** |
| 923 |
Returns the transition of this page |
| 924 |
|
| 925 |
\returns a pointer to a PageTransition structure that |
| 926 |
defines how transition to this page shall be performed. |
| 927 |
|
| 928 |
\note The PageTransition structure is owned by this page, and will |
| 929 |
automatically be destroyed when this page class is |
| 930 |
destroyed. |
| 931 |
**/ |
| 932 |
PageTransition *transition() const; |
| 933 |
|
| 934 |
/** |
| 935 |
Gets the page action specified, or NULL if there is no action. |
| 936 |
|
| 937 |
\since 0.6 |
| 938 |
**/ |
| 939 |
Link *action(PageAction act) const; |
| 940 |
|
| 941 |
/** |
| 942 |
Types of orientations that are possible |
| 943 |
*/ |
| 944 |
enum Orientation |
| 945 |
{ |
| 946 |
Landscape, ///< Landscape orientation (portrait, with 90 degrees clockwise rotation ) |
| 947 |
Portrait, ///< Normal portrait orientation |
| 948 |
Seascape, ///< Seascape orientation (portrait, with 270 degrees clockwise rotation) |
| 949 |
UpsideDown ///< Upside down orientation (portrait, with 180 degrees rotation) |
| 950 |
}; |
| 951 |
|
| 952 |
/** |
| 953 |
The orientation of the page |
| 954 |
*/ |
| 955 |
Orientation orientation() const; |
| 956 |
|
| 957 |
/** |
| 958 |
The default CTM |
| 959 |
*/ |
| 960 |
void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown); |
| 961 |
|
| 962 |
/** |
| 963 |
Gets the links of the page |
| 964 |
*/ |
| 965 |
QList<Link *> links() const; |
| 966 |
|
| 967 |
/** |
| 968 |
Returns the annotations of the page |
| 969 |
|
| 970 |
\note If you call this method twice, you get different objects |
| 971 |
pointing to the same annotations (see Annotation). |
| 972 |
The caller owns the returned objects and they should be deleted |
| 973 |
when no longer required. |
| 974 |
*/ |
| 975 |
QList<Annotation *> annotations() const; |
| 976 |
|
| 977 |
/** |
| 978 |
Returns the annotations of the page |
| 979 |
|
| 980 |
\param subtypes the subtypes of annotations you are interested in |
| 981 |
|
| 982 |
\note If you call this method twice, you get different objects |
| 983 |
pointing to the same annotations (see Annotation). |
| 984 |
The caller owns the returned objects and they should be deleted |
| 985 |
when no longer required. |
| 986 |
|
| 987 |
\since 0.28 |
| 988 |
*/ |
| 989 |
QList<Annotation *> annotations(const QSet<Annotation::SubType> &subtypes) const; |
| 990 |
|
| 991 |
/** |
| 992 |
Adds an annotation to the page |
| 993 |
|
| 994 |
\note Ownership of the annotation object stays with the caller, who can |
| 995 |
delete it at any time. |
| 996 |
\since 0.20 |
| 997 |
*/ |
| 998 |
void addAnnotation(const Annotation *ann); |
| 999 |
|
| 1000 |
/** |
| 1001 |
Removes an annotation from the page and destroys the annotation object |
| 1002 |
|
| 1003 |
\note There mustn't be other Annotation objects pointing this annotation |
| 1004 |
\since 0.20 |
| 1005 |
*/ |
| 1006 |
void removeAnnotation(const Annotation *ann); |
| 1007 |
|
| 1008 |
/** |
| 1009 |
Returns the form fields on the page |
| 1010 |
The caller gets the ownership of the returned objects. |
| 1011 |
|
| 1012 |
\since 0.6 |
| 1013 |
*/ |
| 1014 |
QList<FormField *> formFields() const; |
| 1015 |
|
| 1016 |
/** |
| 1017 |
Returns the page duration. That is the time, in seconds, that the page |
| 1018 |
should be displayed before the presentation automatically advances to the next page. |
| 1019 |
Returns < 0 if duration is not set. |
| 1020 |
|
| 1021 |
\since 0.6 |
| 1022 |
*/ |
| 1023 |
double duration() const; |
| 1024 |
|
| 1025 |
/** |
| 1026 |
Returns the label of the page, or a null string is the page has no label. |
| 1027 |
|
| 1028 |
\since 0.6 |
| 1029 |
**/ |
| 1030 |
QString label() const; |
| 1031 |
|
| 1032 |
/** |
| 1033 |
Returns the index of the page. |
| 1034 |
|
| 1035 |
\since 0.70 |
| 1036 |
**/ |
| 1037 |
int index() const; |
| 1038 |
|
| 1039 |
private: |
| 1040 |
Q_DISABLE_COPY(Page) |
| 1041 |
|
| 1042 |
Page(DocumentData *doc, int index); |
| 1043 |
PageData *m_page; |
| 1044 |
}; |
| 1045 |
|
| 1046 |
/** |
| 1047 |
\brief Item in the outline of a PDF document |
| 1048 |
|
| 1049 |
Represents an item in the outline of PDF document, i.e. a name, an internal or external link and a set of child items. |
| 1050 |
|
| 1051 |
\since 0.74 |
| 1052 |
**/ |
| 1053 |
class POPPLER_QT5_EXPORT OutlineItem |
| 1054 |
{ |
| 1055 |
friend class Document; |
| 1056 |
|
| 1057 |
public: |
| 1058 |
/** |
| 1059 |
Constructs a null item, i.e. one that does not represent a valid item in the outline of some PDF document. |
| 1060 |
**/ |
| 1061 |
OutlineItem(); |
| 1062 |
~OutlineItem(); |
| 1063 |
|
| 1064 |
OutlineItem(const OutlineItem &other); |
| 1065 |
OutlineItem &operator=(const OutlineItem &other); |
| 1066 |
|
| 1067 |
OutlineItem(OutlineItem &&other) noexcept; |
| 1068 |
OutlineItem &operator=(OutlineItem &&other) noexcept; |
| 1069 |
|
| 1070 |
/** |
| 1071 |
Indicates whether an item is null, i.e. whether it does not represent a valid item in the outline of some PDF document. |
| 1072 |
**/ |
| 1073 |
bool isNull() const; |
| 1074 |
|
| 1075 |
/** |
| 1076 |
The name of the item which should be displayed to the user. |
| 1077 |
**/ |
| 1078 |
QString name() const; |
| 1079 |
|
| 1080 |
/** |
| 1081 |
Indicates whether the item should initially be display in an expanded or collapsed state. |
| 1082 |
**/ |
| 1083 |
bool isOpen() const; |
| 1084 |
|
| 1085 |
/** |
| 1086 |
The destination referred to by this item. |
| 1087 |
|
| 1088 |
\returns a shared pointer to an immutable link destination |
| 1089 |
**/ |
| 1090 |
QSharedPointer<const LinkDestination> destination() const; |
| 1091 |
|
| 1092 |
/** |
| 1093 |
The external file name of the document to which the \see destination refers |
| 1094 |
|
| 1095 |
\returns a string with the external file name or an empty string if there is none |
| 1096 |
*/ |
| 1097 |
QString externalFileName() const; |
| 1098 |
|
| 1099 |
/** |
| 1100 |
The URI to which the item links |
| 1101 |
|
| 1102 |
\returns a string with the URI which this item links or an empty string if there is none |
| 1103 |
**/ |
| 1104 |
QString uri() const; |
| 1105 |
|
| 1106 |
/** |
| 1107 |
Determines if this item has any child items |
| 1108 |
|
| 1109 |
\returns true if there are any child items |
| 1110 |
**/ |
| 1111 |
bool hasChildren() const; |
| 1112 |
|
| 1113 |
/** |
| 1114 |
Gets the child items of this item |
| 1115 |
|
| 1116 |
\returns a vector outline items, empty if there are none |
| 1117 |
**/ |
| 1118 |
QVector<OutlineItem> children() const; |
| 1119 |
|
| 1120 |
private: |
| 1121 |
explicit OutlineItem(OutlineItemData *data); |
| 1122 |
OutlineItemData *m_data; |
| 1123 |
}; |
| 1124 |
|
| 1125 |
/** |
| 1126 |
\brief PDF document. |
| 1127 |
|
| 1128 |
The Document class represents a PDF document: its pages, and all the global |
| 1129 |
properties, metadata, etc. |
| 1130 |
|
| 1131 |
\section ownership Ownership of the returned objects |
| 1132 |
|
| 1133 |
All the functions that returns class pointers create new object, and the |
| 1134 |
responsibility of those is given to the callee. |
| 1135 |
|
| 1136 |
The only exception is \link Poppler::Page::transition() Page::transition()\endlink. |
| 1137 |
|
| 1138 |
\section document-loading Loading |
| 1139 |
|
| 1140 |
To get a Document, you have to load it via the load() & loadFromData() |
| 1141 |
functions. |
| 1142 |
|
| 1143 |
In all the functions that have passwords as arguments, they \b must be Latin1 |
| 1144 |
encoded. If you have a password that is a UTF-8 string, you need to use |
| 1145 |
QString::toLatin1() (or similar) to convert the password first. |
| 1146 |
If you have a UTF-8 character array, consider converting it to a QString first |
| 1147 |
(QString::fromUtf8(), or similar) before converting to Latin1 encoding. |
| 1148 |
|
| 1149 |
\section document-rendering Rendering |
| 1150 |
|
| 1151 |
To render pages of a document, you have different Document functions to set |
| 1152 |
various options. |
| 1153 |
|
| 1154 |
\subsection document-rendering-backend Backends |
| 1155 |
|
| 1156 |
%Poppler offers a different backends for rendering the pages. Currently |
| 1157 |
there are two backends (see #RenderBackend), but only the Splash engine works |
| 1158 |
well and has been tested. |
| 1159 |
|
| 1160 |
The available rendering backends can be discovered via availableRenderBackends(). |
| 1161 |
The current rendering backend can be changed using setRenderBackend(). |
| 1162 |
Please note that setting a backend not listed in the available ones |
| 1163 |
will always result in null QImage's. |
| 1164 |
|
| 1165 |
\section document-cms Color management support |
| 1166 |
|
| 1167 |
%Poppler, if compiled with this support, provides functions to handle color |
| 1168 |
profiles. |
| 1169 |
|
| 1170 |
To know whether the %Poppler version you are using has support for color |
| 1171 |
management, you can query Poppler::isCmsAvailable(). In case it is not |
| 1172 |
available, all the color management-related functions will either do nothing |
| 1173 |
or return null. |
| 1174 |
*/ |
| 1175 |
class POPPLER_QT5_EXPORT Document |
| 1176 |
{ |
| 1177 |
friend class Page; |
| 1178 |
friend class DocumentData; |
| 1179 |
|
| 1180 |
public: |
| 1181 |
/** |
| 1182 |
The page mode |
| 1183 |
*/ |
| 1184 |
enum PageMode |
| 1185 |
{ |
| 1186 |
UseNone, ///< No mode - neither document outline nor thumbnail images are visible |
| 1187 |
UseOutlines, ///< Document outline visible |
| 1188 |
UseThumbs, ///< Thumbnail images visible |
| 1189 |
FullScreen, ///< Fullscreen mode (no menubar, windows controls etc) |
| 1190 |
UseOC, ///< Optional content group panel visible |
| 1191 |
UseAttach ///< Attachments panel visible |
| 1192 |
}; |
| 1193 |
|
| 1194 |
/** |
| 1195 |
The page layout |
| 1196 |
*/ |
| 1197 |
enum PageLayout |
| 1198 |
{ |
| 1199 |
NoLayout, ///< Layout not specified |
| 1200 |
SinglePage, ///< Display a single page |
| 1201 |
OneColumn, ///< Display a single column of pages |
| 1202 |
TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left |
| 1203 |
TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right |
| 1204 |
TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left |
| 1205 |
TwoPageRight ///< Display the pages two at a time, with odd-numbered pages on the right |
| 1206 |
}; |
| 1207 |
|
| 1208 |
/** |
| 1209 |
The render backends available |
| 1210 |
|
| 1211 |
\since 0.6 |
| 1212 |
*/ |
| 1213 |
enum RenderBackend |
| 1214 |
{ |
| 1215 |
SplashBackend, ///< Splash backend |
| 1216 |
ArthurBackend, ///< \deprecated The old name of the QPainter backend |
| 1217 |
QPainterBackend = ArthurBackend ///< @since 20.11 |
| 1218 |
}; |
| 1219 |
|
| 1220 |
/** |
| 1221 |
The render hints available |
| 1222 |
|
| 1223 |
\since 0.6 |
| 1224 |
*/ |
| 1225 |
enum RenderHint |
| 1226 |
{ |
| 1227 |
Antialiasing = 0x00000001, ///< Antialiasing for graphics |
| 1228 |
TextAntialiasing = 0x00000002, ///< Antialiasing for text |
| 1229 |
TextHinting = 0x00000004, ///< Hinting for text \since 0.12.1 |
| 1230 |
TextSlightHinting = 0x00000008, ///< Lighter hinting for text when combined with TextHinting \since 0.18 |
| 1231 |
OverprintPreview = 0x00000010, ///< Overprint preview \since 0.22 |
| 1232 |
ThinLineSolid = 0x00000020, ///< Enhance thin lines solid \since 0.24 |
| 1233 |
ThinLineShape = 0x00000040, ///< Enhance thin lines shape. Wins over ThinLineSolid \since 0.24 |
| 1234 |
IgnorePaperColor = 0x00000080, ///< Do not compose with the paper color \since 0.35 |
| 1235 |
HideAnnotations = 0x00000100 ///< Do not render annotations \since 0.60 |
| 1236 |
}; |
| 1237 |
Q_DECLARE_FLAGS(RenderHints, RenderHint) |
| 1238 |
|
| 1239 |
/** |
| 1240 |
Form types |
| 1241 |
|
| 1242 |
\since 0.22 |
| 1243 |
*/ |
| 1244 |
enum FormType |
| 1245 |
{ |
| 1246 |
NoForm, ///< Document doesn't contain forms |
| 1247 |
AcroForm, ///< AcroForm |
| 1248 |
XfaForm ///< Adobe XML Forms Architecture (XFA), currently unsupported |
| 1249 |
}; |
| 1250 |
|
| 1251 |
/** |
| 1252 |
Set a color display profile for the current document. |
| 1253 |
|
| 1254 |
\param outputProfileA is a \c cmsHPROFILE of the LCMS library. |
| 1255 |
|
| 1256 |
\note This should be called before any rendering happens. |
| 1257 |
|
| 1258 |
\note It is assumed that poppler takes over the owernship of the corresponding cmsHPROFILE. In particular, |
| 1259 |
it is no longer the caller's responsibility to close the profile after use. |
| 1260 |
|
| 1261 |
\since 0.12 |
| 1262 |
*/ |
| 1263 |
void setColorDisplayProfile(void *outputProfileA); |
| 1264 |
/** |
| 1265 |
Set a color display profile for the current document. |
| 1266 |
|
| 1267 |
\param name is the name of the display profile to set. |
| 1268 |
|
| 1269 |
\note This should be called before any rendering happens. |
| 1270 |
|
| 1271 |
\since 0.12 |
| 1272 |
*/ |
| 1273 |
void setColorDisplayProfileName(const QString &name); |
| 1274 |
/** |
| 1275 |
Return the current RGB profile. |
| 1276 |
|
| 1277 |
\return a \c cmsHPROFILE of the LCMS library. |
| 1278 |
|
| 1279 |
\note The returned profile stays a property of poppler and shall NOT be closed by the user. It's |
| 1280 |
existence is guaranteed for as long as this instance of the Document class is not deleted. |
| 1281 |
|
| 1282 |
\since 0.12 |
| 1283 |
*/ |
| 1284 |
void *colorRgbProfile() const; |
| 1285 |
/** |
| 1286 |
Return the current display profile. |
| 1287 |
|
| 1288 |
\return a \c cmsHPROFILE of the LCMS library. |
| 1289 |
|
| 1290 |
\note The returned profile stays a property of poppler and shall NOT be closed by the user. It's |
| 1291 |
existence is guaranteed for as long as this instance of the Document class is not deleted. |
| 1292 |
|
| 1293 |
\since 0.12 |
| 1294 |
*/ |
| 1295 |
void *colorDisplayProfile() const; |
| 1296 |
|
| 1297 |
/** |
| 1298 |
Load the document from a file on disk |
| 1299 |
|
| 1300 |
\param filePath the name (and path, if required) of the file to load |
| 1301 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1302 |
loading the file |
| 1303 |
\param userPassword the Latin1-encoded user ("open") password |
| 1304 |
to use in loading the file |
| 1305 |
|
| 1306 |
\return the loaded document, or NULL on error |
| 1307 |
|
| 1308 |
\note The caller owns the pointer to Document, and this should |
| 1309 |
be deleted when no longer required. |
| 1310 |
|
| 1311 |
\warning The returning document may be locked if a password is required |
| 1312 |
to open the file, and one is not provided (as the userPassword). |
| 1313 |
*/ |
| 1314 |
static Document *load(const QString &filePath, const QByteArray &ownerPassword = QByteArray(), const QByteArray &userPassword = QByteArray()); |
| 1315 |
|
| 1316 |
/** |
| 1317 |
Load the document from a device |
| 1318 |
|
| 1319 |
\param device the device of the data to load |
| 1320 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1321 |
loading the file |
| 1322 |
\param userPassword the Latin1-encoded user ("open") password |
| 1323 |
to use in loading the file |
| 1324 |
|
| 1325 |
\return the loaded document, or NULL on error |
| 1326 |
|
| 1327 |
\note The caller owns the pointer to Document, and this should |
| 1328 |
be deleted when no longer required. |
| 1329 |
|
| 1330 |
\note The ownership of the device stays with the caller. |
| 1331 |
|
| 1332 |
\note if the file is on disk it is recommended to use the other load overload |
| 1333 |
since it is less resource intensive |
| 1334 |
|
| 1335 |
\warning The returning document may be locked if a password is required |
| 1336 |
to open the file, and one is not provided (as the userPassword). |
| 1337 |
|
| 1338 |
\since 0.85 |
| 1339 |
*/ |
| 1340 |
static Document *load(QIODevice *device, const QByteArray &ownerPassword = QByteArray(), const QByteArray &userPassword = QByteArray()); |
| 1341 |
|
| 1342 |
/** |
| 1343 |
Load the document from memory |
| 1344 |
|
| 1345 |
\param fileContents the file contents. They are copied so there is no need |
| 1346 |
to keep the byte array around for the full life time of |
| 1347 |
the document. |
| 1348 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1349 |
loading the file |
| 1350 |
\param userPassword the Latin1-encoded user ("open") password |
| 1351 |
to use in loading the file |
| 1352 |
|
| 1353 |
\return the loaded document, or NULL on error |
| 1354 |
|
| 1355 |
\note The caller owns the pointer to Document, and this should |
| 1356 |
be deleted when no longer required. |
| 1357 |
|
| 1358 |
\warning The returning document may be locked if a password is required |
| 1359 |
to open the file, and one is not provided (as the userPassword). |
| 1360 |
|
| 1361 |
\since 0.6 |
| 1362 |
*/ |
| 1363 |
static Document *loadFromData(const QByteArray &fileContents, const QByteArray &ownerPassword = QByteArray(), const QByteArray &userPassword = QByteArray()); |
| 1364 |
|
| 1365 |
/** |
| 1366 |
Get a specified Page |
| 1367 |
|
| 1368 |
Note that this follows the PDF standard of being zero based - if you |
| 1369 |
want the first page, then you need an index of zero. |
| 1370 |
|
| 1371 |
The caller gets the ownership of the returned object. |
| 1372 |
|
| 1373 |
This function can return nullptr if for some reason the page can't be properly parsed. |
| 1374 |
|
| 1375 |
\param index the page number index |
| 1376 |
|
| 1377 |
\warning The Page object returned by this method internally stores a pointer |
| 1378 |
to the document that it was created from. This pointer will go stale if you |
| 1379 |
delete the Document object. Therefore the Document object needs to be kept alive |
| 1380 |
as long as you want to use the Page object. |
| 1381 |
*/ |
| 1382 |
Page *page(int index) const; |
| 1383 |
|
| 1384 |
/** |
| 1385 |
\overload |
| 1386 |
|
| 1387 |
|
| 1388 |
The intent is that you can pass in a label like \c "ix" and |
| 1389 |
get the page with that label (which might be in the table of |
| 1390 |
contents), or pass in \c "1" and get the page that the user |
| 1391 |
expects (which might not be the first page, if there is a |
| 1392 |
title page and a table of contents). |
| 1393 |
|
| 1394 |
\param label the page label |
| 1395 |
*/ |
| 1396 |
Page *page(const QString &label) const; |
| 1397 |
|
| 1398 |
/** |
| 1399 |
The number of pages in the document |
| 1400 |
*/ |
| 1401 |
int numPages() const; |
| 1402 |
|
| 1403 |
/** |
| 1404 |
The type of mode that should be used by the application |
| 1405 |
when the document is opened. Note that while this is |
| 1406 |
called page mode, it is really viewer application mode. |
| 1407 |
*/ |
| 1408 |
PageMode pageMode() const; |
| 1409 |
|
| 1410 |
/** |
| 1411 |
The layout that pages should be shown in when the document |
| 1412 |
is first opened. This basically describes how pages are |
| 1413 |
shown relative to each other. |
| 1414 |
*/ |
| 1415 |
PageLayout pageLayout() const; |
| 1416 |
|
| 1417 |
/** |
| 1418 |
The predominant reading order for text as supplied by |
| 1419 |
the document's viewer preferences. |
| 1420 |
|
| 1421 |
\since 0.26 |
| 1422 |
*/ |
| 1423 |
Qt::LayoutDirection textDirection() const; |
| 1424 |
|
| 1425 |
/** |
| 1426 |
Provide the passwords required to unlock the document |
| 1427 |
|
| 1428 |
\param ownerPassword the Latin1-encoded owner password to use in |
| 1429 |
loading the file |
| 1430 |
\param userPassword the Latin1-encoded user ("open") password |
| 1431 |
to use in loading the file |
| 1432 |
*/ |
| 1433 |
bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword); |
| 1434 |
|
| 1435 |
/** |
| 1436 |
Determine if the document is locked |
| 1437 |
*/ |
| 1438 |
bool isLocked() const; |
| 1439 |
|
| 1440 |
/** |
| 1441 |
The date associated with the document |
| 1442 |
|
| 1443 |
You would use this method with something like: |
| 1444 |
\code |
| 1445 |
QDateTime created = m_doc->date("CreationDate"); |
| 1446 |
QDateTime modified = m_doc->date("ModDate"); |
| 1447 |
\endcode |
| 1448 |
|
| 1449 |
The available dates are: |
| 1450 |
- CreationDate: the date of creation of the document |
| 1451 |
- ModDate: the date of the last change in the document |
| 1452 |
|
| 1453 |
\param type the type of date that is required |
| 1454 |
*/ |
| 1455 |
QDateTime date(const QString &type) const; |
| 1456 |
|
| 1457 |
/** |
| 1458 |
Set the Info dict date entry specified by \param key to \param val |
| 1459 |
|
| 1460 |
\returns true on success, false on failure |
| 1461 |
*/ |
| 1462 |
bool setDate(const QString &key, const QDateTime &val); |
| 1463 |
|
| 1464 |
/** |
| 1465 |
The date of the creation of the document |
| 1466 |
*/ |
| 1467 |
QDateTime creationDate() const; |
| 1468 |
|
| 1469 |
/** |
| 1470 |
Set the creation date of the document to \param val |
| 1471 |
|
| 1472 |
\returns true on success, false on failure |
| 1473 |
*/ |
| 1474 |
bool setCreationDate(const QDateTime &val); |
| 1475 |
|
| 1476 |
/** |
| 1477 |
The date of the last change in the document |
| 1478 |
*/ |
| 1479 |
QDateTime modificationDate() const; |
| 1480 |
|
| 1481 |
/** |
| 1482 |
Set the modification date of the document to \param val |
| 1483 |
|
| 1484 |
\returns true on success, false on failure |
| 1485 |
*/ |
| 1486 |
bool setModificationDate(const QDateTime &val); |
| 1487 |
|
| 1488 |
/** |
| 1489 |
Get specified information associated with the document |
| 1490 |
|
| 1491 |
You would use this method with something like: |
| 1492 |
\code |
| 1493 |
QString title = m_doc->info("Title"); |
| 1494 |
QString subject = m_doc->info("Subject"); |
| 1495 |
\endcode |
| 1496 |
|
| 1497 |
In addition to \c Title and \c Subject, other information that may |
| 1498 |
be available include \c Author, \c Keywords, \c Creator and \c Producer. |
| 1499 |
|
| 1500 |
\param type the information that is required |
| 1501 |
|
| 1502 |
\sa infoKeys() to get a list of the available keys |
| 1503 |
*/ |
| 1504 |
QString info(const QString &type) const; |
| 1505 |
|
| 1506 |
/** |
| 1507 |
Set the value of the document's Info dictionary entry specified by \param key to \param val |
| 1508 |
|
| 1509 |
\returns true on success, false on failure |
| 1510 |
*/ |
| 1511 |
bool setInfo(const QString &key, const QString &val); |
| 1512 |
|
| 1513 |
/** |
| 1514 |
The title of the document |
| 1515 |
*/ |
| 1516 |
QString title() const; |
| 1517 |
|
| 1518 |
/** |
| 1519 |
Set the title of the document to \param val |
| 1520 |
|
| 1521 |
\returns true on success, false on failure |
| 1522 |
*/ |
| 1523 |
bool setTitle(const QString &val); |
| 1524 |
|
| 1525 |
/** |
| 1526 |
The author of the document |
| 1527 |
*/ |
| 1528 |
QString author() const; |
| 1529 |
|
| 1530 |
/** |
| 1531 |
Set the author of the document to \param val |
| 1532 |
|
| 1533 |
\returns true on success, false on failure |
| 1534 |
*/ |
| 1535 |
bool setAuthor(const QString &val); |
| 1536 |
|
| 1537 |
/** |
| 1538 |
The subject of the document |
| 1539 |
*/ |
| 1540 |
QString subject() const; |
| 1541 |
|
| 1542 |
/** |
| 1543 |
Set the subject of the document to \param val |
| 1544 |
|
| 1545 |
\returns true on success, false on failure |
| 1546 |
*/ |
| 1547 |
bool setSubject(const QString &val); |
| 1548 |
|
| 1549 |
/** |
| 1550 |
The keywords of the document |
| 1551 |
*/ |
| 1552 |
QString keywords() const; |
| 1553 |
|
| 1554 |
/** |
| 1555 |
Set the keywords of the document to \param val |
| 1556 |
|
| 1557 |
\returns true on success, false on failure |
| 1558 |
*/ |
| 1559 |
bool setKeywords(const QString &val); |
| 1560 |
|
| 1561 |
/** |
| 1562 |
The creator of the document |
| 1563 |
*/ |
| 1564 |
QString creator() const; |
| 1565 |
|
| 1566 |
/** |
| 1567 |
Set the creator of the document to \param val |
| 1568 |
|
| 1569 |
\returns true on success, false on failure |
| 1570 |
*/ |
| 1571 |
bool setCreator(const QString &val); |
| 1572 |
|
| 1573 |
/** |
| 1574 |
The producer of the document |
| 1575 |
*/ |
| 1576 |
QString producer() const; |
| 1577 |
|
| 1578 |
/** |
| 1579 |
Set the producer of the document to \param val |
| 1580 |
|
| 1581 |
\returns true on success, false on failure |
| 1582 |
*/ |
| 1583 |
bool setProducer(const QString &val); |
| 1584 |
|
| 1585 |
/** |
| 1586 |
Remove the document's Info dictionary |
| 1587 |
|
| 1588 |
\returns true on success, false on failure |
| 1589 |
*/ |
| 1590 |
bool removeInfo(); |
| 1591 |
|
| 1592 |
/** |
| 1593 |
Obtain a list of the available string information keys. |
| 1594 |
*/ |
| 1595 |
QStringList infoKeys() const; |
| 1596 |
|
| 1597 |
/** |
| 1598 |
Test if the document is encrypted |
| 1599 |
*/ |
| 1600 |
bool isEncrypted() const; |
| 1601 |
|
| 1602 |
/** |
| 1603 |
Test if the document is linearised |
| 1604 |
|
| 1605 |
In some cases, this is called "fast web view", since it |
| 1606 |
is mostly an optimisation for viewing over the Web. |
| 1607 |
*/ |
| 1608 |
bool isLinearized() const; |
| 1609 |
|
| 1610 |
/** |
| 1611 |
Test if the permissions on the document allow it to be |
| 1612 |
printed |
| 1613 |
*/ |
| 1614 |
bool okToPrint() const; |
| 1615 |
|
| 1616 |
/** |
| 1617 |
Test if the permissions on the document allow it to be |
| 1618 |
printed at high resolution |
| 1619 |
*/ |
| 1620 |
bool okToPrintHighRes() const; |
| 1621 |
|
| 1622 |
/** |
| 1623 |
Test if the permissions on the document allow it to be |
| 1624 |
changed. |
| 1625 |
|
| 1626 |
\note depending on the type of change, it may be more |
| 1627 |
appropriate to check other properties as well. |
| 1628 |
*/ |
| 1629 |
bool okToChange() const; |
| 1630 |
|
| 1631 |
/** |
| 1632 |
Test if the permissions on the document allow the |
| 1633 |
contents to be copied / extracted |
| 1634 |
*/ |
| 1635 |
bool okToCopy() const; |
| 1636 |
|
| 1637 |
/** |
| 1638 |
Test if the permissions on the document allow annotations |
| 1639 |
to be added or modified, and interactive form fields (including |
| 1640 |
signature fields) to be completed. |
| 1641 |
*/ |
| 1642 |
bool okToAddNotes() const; |
| 1643 |
|
| 1644 |
/** |
| 1645 |
Test if the permissions on the document allow interactive |
| 1646 |
form fields (including signature fields) to be completed. |
| 1647 |
|
| 1648 |
\note this can be true even if okToAddNotes() is false - this |
| 1649 |
means that only form completion is permitted. |
| 1650 |
*/ |
| 1651 |
bool okToFillForm() const; |
| 1652 |
|
| 1653 |
/** |
| 1654 |
Test if the permissions on the document allow interactive |
| 1655 |
form fields (including signature fields) to be set, created and |
| 1656 |
modified |
| 1657 |
*/ |
| 1658 |
bool okToCreateFormFields() const; |
| 1659 |
|
| 1660 |
/** |
| 1661 |
Test if the permissions on the document allow content extraction |
| 1662 |
(text and perhaps other content) for accessibility usage (eg for |
| 1663 |
a screen reader) |
| 1664 |
*/ |
| 1665 |
bool okToExtractForAccessibility() const; |
| 1666 |
|
| 1667 |
/** |
| 1668 |
Test if the permissions on the document allow it to be |
| 1669 |
"assembled" - insertion, rotation and deletion of pages; |
| 1670 |
or creation of bookmarks and thumbnail images. |
| 1671 |
|
| 1672 |
\note this can be true even if okToChange() is false |
| 1673 |
*/ |
| 1674 |
bool okToAssemble() const; |
| 1675 |
|
| 1676 |
/** |
| 1677 |
The version of the PDF specification that the document |
| 1678 |
conforms to |
| 1679 |
|
| 1680 |
\param major an optional pointer to a variable where store the |
| 1681 |
"major" number of the version |
| 1682 |
\param minor an optional pointer to a variable where store the |
| 1683 |
"minor" number of the version |
| 1684 |
|
| 1685 |
\deprecated Will be removed in the Qt6 interface. Use the method |
| 1686 |
returning a PdfVersion object instead! |
| 1687 |
|
| 1688 |
\since 0.12 |
| 1689 |
*/ |
| 1690 |
Q_DECL_DEPRECATED void getPdfVersion(int *major, int *minor) const; |
| 1691 |
|
| 1692 |
/** \brief The version specification of a pdf file */ |
| 1693 |
struct PdfVersion |
| 1694 |
{ |
| 1695 |
int major; |
| 1696 |
int minor; |
| 1697 |
}; |
| 1698 |
|
| 1699 |
/** |
| 1700 |
The version of the PDF specification that the document |
| 1701 |
conforms to |
| 1702 |
|
| 1703 |
\since 21.08 |
| 1704 |
*/ |
| 1705 |
PdfVersion getPdfVersion() const; |
| 1706 |
|
| 1707 |
/** |
| 1708 |
The fonts within the PDF document. |
| 1709 |
|
| 1710 |
This is a shorthand for getting all the fonts at once. |
| 1711 |
|
| 1712 |
\note this can take a very long time to run with a large |
| 1713 |
document. You may wish to use a FontIterator if you have more |
| 1714 |
than say 20 pages |
| 1715 |
|
| 1716 |
\see newFontIterator() |
| 1717 |
*/ |
| 1718 |
QList<FontInfo> fonts() const; |
| 1719 |
|
| 1720 |
/** |
| 1721 |
Creates a new FontIterator object for font scanning. |
| 1722 |
|
| 1723 |
The new iterator can be used for reading the font information of the |
| 1724 |
document, reading page by page. |
| 1725 |
|
| 1726 |
The caller is responsible for the returned object, ie it should freed |
| 1727 |
it when no more useful. |
| 1728 |
|
| 1729 |
\param startPage the initial page from which start reading fonts |
| 1730 |
|
| 1731 |
\see fonts() |
| 1732 |
|
| 1733 |
\since 0.12 |
| 1734 |
*/ |
| 1735 |
FontIterator *newFontIterator(int startPage = 0) const; |
| 1736 |
|
| 1737 |
/** |
| 1738 |
The font data if the font is an embedded one. |
| 1739 |
|
| 1740 |
\since 0.10 |
| 1741 |
*/ |
| 1742 |
QByteArray fontData(const FontInfo &fi) const; |
| 1743 |
|
| 1744 |
/** |
| 1745 |
The documents embedded within the PDF document. |
| 1746 |
|
| 1747 |
\note there are two types of embedded document - this call |
| 1748 |
only accesses documents that are embedded at the document level. |
| 1749 |
*/ |
| 1750 |
QList<EmbeddedFile *> embeddedFiles() const; |
| 1751 |
|
| 1752 |
/** |
| 1753 |
Whether there are any documents embedded in this PDF document. |
| 1754 |
*/ |
| 1755 |
bool hasEmbeddedFiles() const; |
| 1756 |
|
| 1757 |
/** |
| 1758 |
Gets the table of contents (TOC) of the Document. |
| 1759 |
|
| 1760 |
The caller is responsible for the returned object. |
| 1761 |
|
| 1762 |
In the tree the tag name is the 'screen' name of the entry. A tag can have |
| 1763 |
attributes. Here follows the list of tag attributes with meaning: |
| 1764 |
- Destination: A string description of the referred destination |
| 1765 |
- DestinationName: A 'named reference' to the viewport |
| 1766 |
- ExternalFileName: A link to a external filename |
| 1767 |
- Open: A bool value that tells whether the subbranch of the item is open or not |
| 1768 |
|
| 1769 |
Resolving the final destination for each item can be done in the following way: |
| 1770 |
- first, checking for 'Destination': if not empty, then a LinkDestination |
| 1771 |
can be constructed straight with it |
| 1772 |
- as second step, if the 'DestinationName' is not empty, then the destination |
| 1773 |
can be resolved using linkDestination() |
| 1774 |
|
| 1775 |
Note also that if 'ExternalFileName' is not emtpy, then the destination refers |
| 1776 |
to that document (and not to the current one). |
| 1777 |
|
| 1778 |
\returns the TOC, or NULL if the Document does not have one |
| 1779 |
*/ |
| 1780 |
Q_DECL_DEPRECATED QDomDocument *toc() const; |
| 1781 |
|
| 1782 |
/** |
| 1783 |
Gets the outline of the document |
| 1784 |
|
| 1785 |
\returns a vector of outline items, empty if there are none |
| 1786 |
|
| 1787 |
\since 0.74 |
| 1788 |
**/ |
| 1789 |
QVector<OutlineItem> outline() const; |
| 1790 |
|
| 1791 |
/** |
| 1792 |
Tries to resolve the named destination \p name. |
| 1793 |
|
| 1794 |
\note this operation starts a search through the whole document |
| 1795 |
|
| 1796 |
\returns a new LinkDestination object if the named destination was |
| 1797 |
actually found, or NULL otherwise |
| 1798 |
*/ |
| 1799 |
LinkDestination *linkDestination(const QString &name); |
| 1800 |
|
| 1801 |
/** |
| 1802 |
Sets the paper color |
| 1803 |
|
| 1804 |
\param color the new paper color |
| 1805 |
*/ |
| 1806 |
void setPaperColor(const QColor &color); |
| 1807 |
/** |
| 1808 |
The paper color |
| 1809 |
|
| 1810 |
The default color is white. |
| 1811 |
*/ |
| 1812 |
QColor paperColor() const; |
| 1813 |
|
| 1814 |
/** |
| 1815 |
Sets the backend used to render the pages. |
| 1816 |
|
| 1817 |
\param backend the new rendering backend |
| 1818 |
|
| 1819 |
\since 0.6 |
| 1820 |
*/ |
| 1821 |
void setRenderBackend(RenderBackend backend); |
| 1822 |
/** |
| 1823 |
The currently set render backend |
| 1824 |
|
| 1825 |
The default backend is \ref SplashBackend |
| 1826 |
|
| 1827 |
\since 0.6 |
| 1828 |
*/ |
| 1829 |
RenderBackend renderBackend() const; |
| 1830 |
|
| 1831 |
/** |
| 1832 |
The available rendering backends. |
| 1833 |
|
| 1834 |
\since 0.6 |
| 1835 |
*/ |
| 1836 |
static QSet<RenderBackend> availableRenderBackends(); |
| 1837 |
|
| 1838 |
/** |
| 1839 |
Sets the render \p hint . |
| 1840 |
|
| 1841 |
\note some hints may not be supported by some rendering backends. |
| 1842 |
|
| 1843 |
\param on whether the flag should be added or removed. |
| 1844 |
|
| 1845 |
\since 0.6 |
| 1846 |
*/ |
| 1847 |
void setRenderHint(RenderHint hint, bool on = true); |
| 1848 |
/** |
| 1849 |
The currently set render hints. |
| 1850 |
|
| 1851 |
\since 0.6 |
| 1852 |
*/ |
| 1853 |
RenderHints renderHints() const; |
| 1854 |
|
| 1855 |
/** |
| 1856 |
Gets a new PS converter for this document. |
| 1857 |
|
| 1858 |
The caller gets the ownership of the returned converter. |
| 1859 |
|
| 1860 |
\since 0.6 |
| 1861 |
*/ |
| 1862 |
PSConverter *psConverter() const; |
| 1863 |
|
| 1864 |
/** |
| 1865 |
Gets a new PDF converter for this document. |
| 1866 |
|
| 1867 |
The caller gets the ownership of the returned converter. |
| 1868 |
|
| 1869 |
\since 0.8 |
| 1870 |
*/ |
| 1871 |
PDFConverter *pdfConverter() const; |
| 1872 |
|
| 1873 |
/** |
| 1874 |
Gets the metadata stream contents |
| 1875 |
|
| 1876 |
\since 0.6 |
| 1877 |
*/ |
| 1878 |
QString metadata() const; |
| 1879 |
|
| 1880 |
/** |
| 1881 |
Test whether this document has "optional content". |
| 1882 |
|
| 1883 |
Optional content is used to optionally turn on (display) |
| 1884 |
and turn off (not display) some elements of the document. |
| 1885 |
The most common use of this is for layers in design |
| 1886 |
applications, but it can be used for a range of things, |
| 1887 |
such as not including some content in printing, and |
| 1888 |
displaying content in the appropriate language. |
| 1889 |
|
| 1890 |
\since 0.8 |
| 1891 |
*/ |
| 1892 |
bool hasOptionalContent() const; |
| 1893 |
|
| 1894 |
/** |
| 1895 |
Itemviews model for optional content. |
| 1896 |
|
| 1897 |
The model is owned by the document. |
| 1898 |
|
| 1899 |
\since 0.8 |
| 1900 |
*/ |
| 1901 |
OptContentModel *optionalContentModel(); |
| 1902 |
|
| 1903 |
/** |
| 1904 |
Resets the form with the details contained in the \p link. |
| 1905 |
|
| 1906 |
\since 24.07 |
| 1907 |
*/ |
| 1908 |
void applyResetFormsLink(const LinkResetForm &link); |
| 1909 |
|
| 1910 |
/** |
| 1911 |
Document-level JavaScript scripts. |
| 1912 |
|
| 1913 |
Returns the list of document level JavaScript scripts to be always |
| 1914 |
executed before any other script. |
| 1915 |
|
| 1916 |
\since 0.10 |
| 1917 |
*/ |
| 1918 |
QStringList scripts() const; |
| 1919 |
|
| 1920 |
/** |
| 1921 |
Describes the flags for additional document actions i.e. |
| 1922 |
for executing document scripts at different events. |
| 1923 |
This flag is used by additionalAction method to return the |
| 1924 |
particular Link. |
| 1925 |
|
| 1926 |
\since 24.07 |
| 1927 |
*/ |
| 1928 |
enum DocumentAdditionalActionsType |
| 1929 |
{ |
| 1930 |
CloseDocument, ///< Performed before closing the document |
| 1931 |
SaveDocumentStart, ///< Performed before saving the document |
| 1932 |
SaveDocumentFinish, ///< Performed after saving the document |
| 1933 |
PrintDocumentStart, ///< Performed before printing the document |
| 1934 |
PrintDocumentFinish, ///< Performed after printing the document |
| 1935 |
}; |
| 1936 |
|
| 1937 |
/** |
| 1938 |
Returns the additional action of the given @p type for the document or |
| 1939 |
@c 0 if no action has been defined. |
| 1940 |
|
| 1941 |
\since 24.07 |
| 1942 |
*/ |
| 1943 |
Link *additionalAction(DocumentAdditionalActionsType type) const; |
| 1944 |
|
| 1945 |
/** |
| 1946 |
The PDF identifiers. |
| 1947 |
|
| 1948 |
\param permanentId an optional pointer to a variable where store the |
| 1949 |
permanent ID of the document |
| 1950 |
\param updateId an optional pointer to a variable where store the |
| 1951 |
update ID of the document |
| 1952 |
|
| 1953 |
\return whether the document has the IDs |
| 1954 |
|
| 1955 |
\since 0.16 |
| 1956 |
*/ |
| 1957 |
bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; |
| 1958 |
|
| 1959 |
/** |
| 1960 |
Returns the type of forms contained in the document |
| 1961 |
|
| 1962 |
\since 0.22 |
| 1963 |
*/ |
| 1964 |
FormType formType() const; |
| 1965 |
|
| 1966 |
/** |
| 1967 |
Returns the calculate order for forms (using their id) |
| 1968 |
|
| 1969 |
\since 0.53 |
| 1970 |
*/ |
| 1971 |
QVector<int> formCalculateOrder() const; |
| 1972 |
|
| 1973 |
/** |
| 1974 |
Returns the signatures of this document. |
| 1975 |
|
| 1976 |
Prefer to use this over getting the signatures for all the pages of the document |
| 1977 |
since there are documents with signatures that don't belong to a given page |
| 1978 |
|
| 1979 |
\since 0.88 |
| 1980 |
*/ |
| 1981 |
QVector<FormFieldSignature *> signatures() const; |
| 1982 |
|
| 1983 |
/** |
| 1984 |
Returns whether the document's XRef table has been reconstructed or not |
| 1985 |
|
| 1986 |
\since 21.06 |
| 1987 |
*/ |
| 1988 |
bool xrefWasReconstructed() const; |
| 1989 |
|
| 1990 |
/** |
| 1991 |
Sets the document's XRef reconstruction callback, so whenever a XRef table |
| 1992 |
reconstruction happens the callback will get triggered. |
| 1993 |
|
| 1994 |
\since 21.06 |
| 1995 |
*/ |
| 1996 |
void setXRefReconstructedCallback(const std::function<void()> &callback); |
| 1997 |
|
| 1998 |
/** |
| 1999 |
Destructor. |
| 2000 |
*/ |
| 2001 |
~Document(); |
| 2002 |
|
| 2003 |
private: |
| 2004 |
Q_DISABLE_COPY(Document) |
| 2005 |
|
| 2006 |
DocumentData *m_doc; |
| 2007 |
|
| 2008 |
explicit Document(DocumentData *dataA); |
| 2009 |
}; |
| 2010 |
|
| 2011 |
class BaseConverterPrivate; |
| 2012 |
class PSConverterPrivate; |
| 2013 |
class PDFConverterPrivate; |
| 2014 |
/** |
| 2015 |
\brief Base converter. |
| 2016 |
|
| 2017 |
This is the base class for the converters. |
| 2018 |
|
| 2019 |
\since 0.8 |
| 2020 |
*/ |
| 2021 |
class POPPLER_QT5_EXPORT BaseConverter |
| 2022 |
{ |
| 2023 |
friend class Document; |
| 2024 |
|
| 2025 |
public: |
| 2026 |
/** |
| 2027 |
Destructor. |
| 2028 |
*/ |
| 2029 |
virtual ~BaseConverter(); |
| 2030 |
|
| 2031 |
/** Sets the output file name. You must set this or the output device. */ |
| 2032 |
void setOutputFileName(const QString &outputFileName); |
| 2033 |
|
| 2034 |
/** |
| 2035 |
* Sets the output device. You must set this or the output file name. |
| 2036 |
* |
| 2037 |
* \since 0.8 |
| 2038 |
*/ |
| 2039 |
void setOutputDevice(QIODevice *device); |
| 2040 |
|
| 2041 |
/** |
| 2042 |
Does the conversion. |
| 2043 |
|
| 2044 |
\return whether the conversion succeeded |
| 2045 |
*/ |
| 2046 |
virtual bool convert() = 0; |
| 2047 |
|
| 2048 |
enum Error |
| 2049 |
{ |
| 2050 |
NoError, |
| 2051 |
FileLockedError, |
| 2052 |
OpenOutputError, |
| 2053 |
NotSupportedInputFileError |
| 2054 |
}; |
| 2055 |
|
| 2056 |
/** |
| 2057 |
Returns the last error |
| 2058 |
\since 0.12.1 |
| 2059 |
*/ |
| 2060 |
Error lastError() const; |
| 2061 |
|
| 2062 |
protected: |
| 2063 |
/// \cond PRIVATE |
| 2064 |
explicit BaseConverter(BaseConverterPrivate &dd); |
| 2065 |
Q_DECLARE_PRIVATE(BaseConverter) |
| 2066 |
BaseConverterPrivate *d_ptr; |
| 2067 |
/// \endcond |
| 2068 |
|
| 2069 |
private: |
| 2070 |
Q_DISABLE_COPY(BaseConverter) |
| 2071 |
}; |
| 2072 |
|
| 2073 |
/** |
| 2074 |
Converts a PDF to PS |
| 2075 |
|
| 2076 |
Sizes have to be in Points (1/72 inch) |
| 2077 |
|
| 2078 |
If you are using QPrinter you can get paper size by doing: |
| 2079 |
\code |
| 2080 |
QPrinter dummy(QPrinter::PrinterResolution); |
| 2081 |
dummy.setFullPage(true); |
| 2082 |
dummy.setPageSize(myPageSize); |
| 2083 |
width = dummy.width(); |
| 2084 |
height = dummy.height(); |
| 2085 |
\endcode |
| 2086 |
|
| 2087 |
\since 0.6 |
| 2088 |
*/ |
| 2089 |
class POPPLER_QT5_EXPORT PSConverter : public BaseConverter |
| 2090 |
{ |
| 2091 |
friend class Document; |
| 2092 |
|
| 2093 |
public: |
| 2094 |
/** |
| 2095 |
Options for the PS export. |
| 2096 |
|
| 2097 |
\since 0.10 |
| 2098 |
*/ |
| 2099 |
enum PSOption |
| 2100 |
{ |
| 2101 |
Printing = 0x00000001, ///< The PS is generated for printing purposes |
| 2102 |
StrictMargins = 0x00000002, |
| 2103 |
ForceRasterization = 0x00000004, |
| 2104 |
PrintToEPS = 0x00000008, ///< Output EPS instead of PS \since 0.20 |
| 2105 |
HideAnnotations = 0x00000010, ///< Don't print annotations \since 0.20 |
| 2106 |
ForceOverprintPreview = 0x00000020 ///< Force rasterized overprint preview during conversion \since 23.09 |
| 2107 |
}; |
| 2108 |
Q_DECLARE_FLAGS(PSOptions, PSOption) |
| 2109 |
|
| 2110 |
/** |
| 2111 |
Destructor. |
| 2112 |
*/ |
| 2113 |
~PSConverter() override; |
| 2114 |
|
| 2115 |
/** Sets the list of pages to print. Mandatory. */ |
| 2116 |
void setPageList(const QList<int> &pageList); |
| 2117 |
|
| 2118 |
/** |
| 2119 |
Sets the title of the PS Document. Optional |
| 2120 |
*/ |
| 2121 |
void setTitle(const QString &title); |
| 2122 |
|
| 2123 |
/** |
| 2124 |
Sets the horizontal DPI. Defaults to 72.0 |
| 2125 |
*/ |
| 2126 |
void setHDPI(double hDPI); |
| 2127 |
|
| 2128 |
/** |
| 2129 |
Sets the vertical DPI. Defaults to 72.0 |
| 2130 |
*/ |
| 2131 |
void setVDPI(double vDPI); |
| 2132 |
|
| 2133 |
/** |
| 2134 |
Sets the rotate. Defaults to not rotated |
| 2135 |
*/ |
| 2136 |
void setRotate(int rotate); |
| 2137 |
|
| 2138 |
/** |
| 2139 |
Sets the output paper width. Has to be set. |
| 2140 |
*/ |
| 2141 |
void setPaperWidth(int paperWidth); |
| 2142 |
|
| 2143 |
/** |
| 2144 |
Sets the output paper height. Has to be set. |
| 2145 |
*/ |
| 2146 |
void setPaperHeight(int paperHeight); |
| 2147 |
|
| 2148 |
/** |
| 2149 |
Sets the output right margin. Defaults to 0 |
| 2150 |
*/ |
| 2151 |
void setRightMargin(int marginRight); |
| 2152 |
|
| 2153 |
/** |
| 2154 |
Sets the output bottom margin. Defaults to 0 |
| 2155 |
*/ |
| 2156 |
void setBottomMargin(int marginBottom); |
| 2157 |
|
| 2158 |
/** |
| 2159 |
Sets the output left margin. Defaults to 0 |
| 2160 |
*/ |
| 2161 |
void setLeftMargin(int marginLeft); |
| 2162 |
|
| 2163 |
/** |
| 2164 |
Sets the output top margin. Defaults to 0 |
| 2165 |
*/ |
| 2166 |
void setTopMargin(int marginTop); |
| 2167 |
|
| 2168 |
/** |
| 2169 |
Defines if margins have to be strictly followed (even if that |
| 2170 |
means changing aspect ratio), or if the margins can be adapted |
| 2171 |
to keep aspect ratio. |
| 2172 |
|
| 2173 |
Defaults to false. |
| 2174 |
*/ |
| 2175 |
void setStrictMargins(bool strictMargins); |
| 2176 |
|
| 2177 |
/** |
| 2178 |
Defines if the page will be rasterized to an image with overprint |
| 2179 |
preview enabled before printing. |
| 2180 |
|
| 2181 |
Defaults to false |
| 2182 |
|
| 2183 |
\since 23.09 |
| 2184 |
*/ |
| 2185 |
void setForceOverprintPreview(bool forceOverprintPreview); |
| 2186 |
|
| 2187 |
/** Defines if the page will be rasterized to an image before printing. Defaults to false */ |
| 2188 |
void setForceRasterize(bool forceRasterize); |
| 2189 |
|
| 2190 |
/** |
| 2191 |
Sets the options for the PS export. |
| 2192 |
|
| 2193 |
\since 0.10 |
| 2194 |
*/ |
| 2195 |
void setPSOptions(PSOptions options); |
| 2196 |
|
| 2197 |
/** |
| 2198 |
The currently set options for the PS export. |
| 2199 |
|
| 2200 |
The default flags are: Printing. |
| 2201 |
|
| 2202 |
\since 0.10 |
| 2203 |
*/ |
| 2204 |
PSOptions psOptions() const; |
| 2205 |
|
| 2206 |
/** |
| 2207 |
Sets a function that will be called each time a page is converted. |
| 2208 |
|
| 2209 |
The payload belongs to the caller. |
| 2210 |
|
| 2211 |
\since 0.16 |
| 2212 |
*/ |
| 2213 |
void setPageConvertedCallback(void (*callback)(int page, void *payload), void *payload); |
| 2214 |
|
| 2215 |
bool convert() override; |
| 2216 |
|
| 2217 |
private: |
| 2218 |
Q_DECLARE_PRIVATE(PSConverter) |
| 2219 |
Q_DISABLE_COPY(PSConverter) |
| 2220 |
|
| 2221 |
explicit PSConverter(DocumentData *document); |
| 2222 |
}; |
| 2223 |
|
| 2224 |
/** |
| 2225 |
Converts a PDF to PDF (thus saves a copy of the document). |
| 2226 |
|
| 2227 |
\since 0.8 |
| 2228 |
*/ |
| 2229 |
class POPPLER_QT5_EXPORT PDFConverter : public BaseConverter |
| 2230 |
{ |
| 2231 |
friend class Document; |
| 2232 |
|
| 2233 |
public: |
| 2234 |
/** |
| 2235 |
Options for the PDF export. |
| 2236 |
*/ |
| 2237 |
enum PDFOption |
| 2238 |
{ |
| 2239 |
WithChanges = 0x00000001 ///< The changes done to the document are saved as well |
| 2240 |
}; |
| 2241 |
Q_DECLARE_FLAGS(PDFOptions, PDFOption) |
| 2242 |
|
| 2243 |
/** |
| 2244 |
Destructor. |
| 2245 |
*/ |
| 2246 |
~PDFConverter() override; |
| 2247 |
|
| 2248 |
/** |
| 2249 |
Sets the options for the PDF export. |
| 2250 |
*/ |
| 2251 |
void setPDFOptions(PDFOptions options); |
| 2252 |
/** |
| 2253 |
The currently set options for the PDF export. |
| 2254 |
*/ |
| 2255 |
PDFOptions pdfOptions() const; |
| 2256 |
|
| 2257 |
/** |
| 2258 |
* Holds data for a new signature |
| 2259 |
* - Common Name of cert to sign (aka nickname) |
| 2260 |
* - password for the cert |
| 2261 |
* - page where to add the signature |
| 2262 |
* - rect for the signature annotation |
| 2263 |
* - text that will be shown inside the rect |
| 2264 |
* - font size and color |
| 2265 |
* - border width and color |
| 2266 |
* - background color |
| 2267 |
* \since 21.01 |
| 2268 |
*/ |
| 2269 |
class POPPLER_QT5_EXPORT NewSignatureData |
| 2270 |
{ |
| 2271 |
public: |
| 2272 |
NewSignatureData(); |
| 2273 |
~NewSignatureData(); |
| 2274 |
NewSignatureData(const NewSignatureData &) = delete; |
| 2275 |
NewSignatureData &operator=(const NewSignatureData &) = delete; |
| 2276 |
|
| 2277 |
QString certNickname() const; |
| 2278 |
void setCertNickname(const QString &certNickname); |
| 2279 |
|
| 2280 |
QString password() const; |
| 2281 |
void setPassword(const QString &password); |
| 2282 |
|
| 2283 |
int page() const; |
| 2284 |
void setPage(int page); |
| 2285 |
|
| 2286 |
QRectF boundingRectangle() const; |
| 2287 |
void setBoundingRectangle(const QRectF &rect); |
| 2288 |
|
| 2289 |
QString signatureText() const; |
| 2290 |
void setSignatureText(const QString &text); |
| 2291 |
|
| 2292 |
/** |
| 2293 |
* If this text is not empty, the signature representation |
| 2294 |
* will split in two, with this text on the left and signatureText |
| 2295 |
* on the right |
| 2296 |
* |
| 2297 |
* \since 21.06 |
| 2298 |
*/ |
| 2299 |
QString signatureLeftText() const; |
| 2300 |
void setSignatureLeftText(const QString &text); |
| 2301 |
|
| 2302 |
/** |
| 2303 |
* Signature's property Reason. |
| 2304 |
* |
| 2305 |
* Default: an empty string. |
| 2306 |
* |
| 2307 |
* \since 21.10 |
| 2308 |
*/ |
| 2309 |
QString reason() const; |
| 2310 |
void setReason(const QString &reason); |
| 2311 |
|
| 2312 |
/** |
| 2313 |
* Signature's property Location. |
| 2314 |
* |
| 2315 |
* Default: an empty string. |
| 2316 |
* |
| 2317 |
* \since 21.10 |
| 2318 |
*/ |
| 2319 |
QString location() const; |
| 2320 |
void setLocation(const QString &location); |
| 2321 |
|
| 2322 |
/** |
| 2323 |
* Default: 10 |
| 2324 |
*/ |
| 2325 |
double fontSize() const; |
| 2326 |
void setFontSize(double fontSize); |
| 2327 |
|
| 2328 |
/** |
| 2329 |
* Default: 20 |
| 2330 |
* |
| 2331 |
* \since 21.06 |
| 2332 |
*/ |
| 2333 |
double leftFontSize() const; |
| 2334 |
void setLeftFontSize(double fontSize); |
| 2335 |
|
| 2336 |
/** |
| 2337 |
* Default: red |
| 2338 |
*/ |
| 2339 |
QColor fontColor() const; |
| 2340 |
void setFontColor(const QColor &color); |
| 2341 |
|
| 2342 |
/** |
| 2343 |
* Default: red |
| 2344 |
*/ |
| 2345 |
QColor borderColor() const; |
| 2346 |
void setBorderColor(const QColor &color); |
| 2347 |
|
| 2348 |
/** |
| 2349 |
* border width in points |
| 2350 |
* |
| 2351 |
* Default: 1.5 |
| 2352 |
* |
| 2353 |
* \since 21.05 |
| 2354 |
*/ |
| 2355 |
double borderWidth() const; |
| 2356 |
void setBorderWidth(double width); |
| 2357 |
|
| 2358 |
/** |
| 2359 |
* Default: QColor(240, 240, 240) |
| 2360 |
*/ |
| 2361 |
QColor backgroundColor() const; |
| 2362 |
void setBackgroundColor(const QColor &color); |
| 2363 |
|
| 2364 |
/** |
| 2365 |
* Default: QUuid::createUuid().toString() |
| 2366 |
*/ |
| 2367 |
QString fieldPartialName() const; |
| 2368 |
void setFieldPartialName(const QString &name); |
| 2369 |
|
| 2370 |
/** |
| 2371 |
* Document owner password (needed if the document that is being signed is password protected) |
| 2372 |
* |
| 2373 |
* Default: no password |
| 2374 |
* |
| 2375 |
* \since 22.02 |
| 2376 |
*/ |
| 2377 |
QByteArray documentOwnerPassword() const; |
| 2378 |
void setDocumentOwnerPassword(const QByteArray &password); |
| 2379 |
|
| 2380 |
/** |
| 2381 |
* Document user password (needed if the document that is being signed is password protected) |
| 2382 |
* |
| 2383 |
* Default: no password |
| 2384 |
* |
| 2385 |
* \since 22.02 |
| 2386 |
*/ |
| 2387 |
QByteArray documentUserPassword() const; |
| 2388 |
void setDocumentUserPassword(const QByteArray &password); |
| 2389 |
|
| 2390 |
/** |
| 2391 |
* Filesystem path to an image file to be used as background |
| 2392 |
* image for the signature annotation widget. |
| 2393 |
* |
| 2394 |
* Default: empty |
| 2395 |
* |
| 2396 |
* \since 22.02 |
| 2397 |
*/ |
| 2398 |
QString imagePath() const; |
| 2399 |
void setImagePath(const QString &path); |
| 2400 |
|
| 2401 |
private: |
| 2402 |
struct NewSignatureDataPrivate; |
| 2403 |
NewSignatureDataPrivate *const d; |
| 2404 |
}; |
| 2405 |
|
| 2406 |
/** |
| 2407 |
Sign PDF at given Annotation / signature form |
| 2408 |
|
| 2409 |
\param data new signature data |
| 2410 |
|
| 2411 |
\return whether the signing succeeded |
| 2412 |
|
| 2413 |
\since 21.01 |
| 2414 |
*/ |
| 2415 |
bool sign(const NewSignatureData &data); |
| 2416 |
|
| 2417 |
/** |
| 2418 |
* \since 25.07 |
| 2419 |
* |
| 2420 |
* BIC/SIC: Merge with SigningResult in poppler-converter and in poppler-annotation and poppler-form |
| 2421 |
*/ |
| 2422 |
enum SigningResult |
| 2423 |
{ |
| 2424 |
SigningSuccess, ///< No error |
| 2425 |
FieldAlreadySigned, ///< Trying to sign a field that is already signed |
| 2426 |
GenericSigningError, ///< Unclassified error |
| 2427 |
InternalError, ///< Unexpected error, likely a bug in poppler |
| 2428 |
KeyMissing, ///< Key not found (Either the input key is not from the list or the available keys has changed underneath) |
| 2429 |
WriteFailed, ///< Write failed (permissions, faulty disk, ...) |
| 2430 |
UserCancelled, ///< User cancelled the process |
| 2431 |
BadPassphrase, ///< User entered bad passphrase |
| 2432 |
}; |
| 2433 |
|
| 2434 |
/** |
| 2435 |
* The last signing result, mostly relevant if \ref sign returns false |
| 2436 |
* \since 25.07 |
| 2437 |
*/ |
| 2438 |
SigningResult lastSigningResult() const; |
| 2439 |
|
| 2440 |
/** |
| 2441 |
* A string with a string that might offer more details of the signing result failure |
| 2442 |
* \note the string here is likely not super useful for end users, but might give more details to a trained supporter / bug triager |
| 2443 |
* \since 25.07 |
| 2444 |
*/ |
| 2445 |
ErrorString lastSigningErrorDetails() const; |
| 2446 |
|
| 2447 |
bool convert() override; |
| 2448 |
|
| 2449 |
private: |
| 2450 |
Q_DECLARE_PRIVATE(PDFConverter) |
| 2451 |
Q_DISABLE_COPY(PDFConverter) |
| 2452 |
|
| 2453 |
explicit PDFConverter(DocumentData *document); |
| 2454 |
}; |
| 2455 |
|
| 2456 |
/** |
| 2457 |
Conversion from PDF date string format to QDateTime |
| 2458 |
*/ |
| 2459 |
POPPLER_QT5_EXPORT Q_DECL_DEPRECATED QDateTime convertDate(char *dateString); |
| 2460 |
|
| 2461 |
/** |
| 2462 |
Conversion from PDF date string format to QDateTime |
| 2463 |
|
| 2464 |
\since 0.64 |
| 2465 |
*/ |
| 2466 |
POPPLER_QT5_EXPORT QDateTime convertDate(const char *dateString); |
| 2467 |
|
| 2468 |
/** |
| 2469 |
Whether the color management functions are available. |
| 2470 |
|
| 2471 |
\since 0.12 |
| 2472 |
*/ |
| 2473 |
POPPLER_QT5_EXPORT bool isCmsAvailable(); |
| 2474 |
|
| 2475 |
/** |
| 2476 |
Whether the overprint preview functionality is available. |
| 2477 |
|
| 2478 |
\since 0.22 |
| 2479 |
*/ |
| 2480 |
POPPLER_QT5_EXPORT bool isOverprintPreviewAvailable(); |
| 2481 |
|
| 2482 |
class SoundData; |
| 2483 |
/** |
| 2484 |
Container class for a sound file in a PDF document. |
| 2485 |
|
| 2486 |
A sound can be either External (in that case should be loaded the file |
| 2487 |
whose url is represented by url() ), or Embedded, and the player has to |
| 2488 |
play the data contained in data(). |
| 2489 |
|
| 2490 |
\since 0.6 |
| 2491 |
*/ |
| 2492 |
class POPPLER_QT5_EXPORT SoundObject |
| 2493 |
{ |
| 2494 |
public: |
| 2495 |
/** |
| 2496 |
The type of sound |
| 2497 |
*/ |
| 2498 |
enum SoundType |
| 2499 |
{ |
| 2500 |
External, ///< The real sound file is external |
| 2501 |
Embedded ///< The sound is contained in the data |
| 2502 |
}; |
| 2503 |
|
| 2504 |
/** |
| 2505 |
The encoding format used for the sound |
| 2506 |
*/ |
| 2507 |
enum SoundEncoding |
| 2508 |
{ |
| 2509 |
Raw, ///< Raw encoding, with unspecified or unsigned values in the range [ 0, 2^B - 1 ] |
| 2510 |
Signed, ///< Twos-complement values |
| 2511 |
muLaw, ///< mu-law-encoded samples |
| 2512 |
ALaw ///< A-law-encoded samples |
| 2513 |
}; |
| 2514 |
|
| 2515 |
/// \cond PRIVATE |
| 2516 |
explicit SoundObject(Sound *popplersound); |
| 2517 |
/// \endcond |
| 2518 |
|
| 2519 |
~SoundObject(); |
| 2520 |
|
| 2521 |
/** |
| 2522 |
Is the sound embedded (SoundObject::Embedded) or external (SoundObject::External)? |
| 2523 |
*/ |
| 2524 |
SoundType soundType() const; |
| 2525 |
|
| 2526 |
/** |
| 2527 |
The URL of the sound file to be played, in case of SoundObject::External |
| 2528 |
*/ |
| 2529 |
QString url() const; |
| 2530 |
|
| 2531 |
/** |
| 2532 |
The data of the sound, in case of SoundObject::Embedded |
| 2533 |
*/ |
| 2534 |
QByteArray data() const; |
| 2535 |
|
| 2536 |
/** |
| 2537 |
The sampling rate of the sound |
| 2538 |
*/ |
| 2539 |
double samplingRate() const; |
| 2540 |
|
| 2541 |
/** |
| 2542 |
The number of sound channels to use to play the sound |
| 2543 |
*/ |
| 2544 |
int channels() const; |
| 2545 |
|
| 2546 |
/** |
| 2547 |
The number of bits per sample value per channel |
| 2548 |
*/ |
| 2549 |
int bitsPerSample() const; |
| 2550 |
|
| 2551 |
/** |
| 2552 |
The encoding used for the sound |
| 2553 |
*/ |
| 2554 |
SoundEncoding soundEncoding() const; |
| 2555 |
|
| 2556 |
private: |
| 2557 |
Q_DISABLE_COPY(SoundObject) |
| 2558 |
|
| 2559 |
SoundData *m_soundData; |
| 2560 |
}; |
| 2561 |
|
| 2562 |
class MovieData; |
| 2563 |
/** |
| 2564 |
Container class for a movie object in a PDF document. |
| 2565 |
|
| 2566 |
\since 0.10 |
| 2567 |
*/ |
| 2568 |
class POPPLER_QT5_EXPORT MovieObject |
| 2569 |
{ |
| 2570 |
friend class AnnotationPrivate; |
| 2571 |
|
| 2572 |
public: |
| 2573 |
/** |
| 2574 |
The play mode for playing the movie |
| 2575 |
*/ |
| 2576 |
enum PlayMode |
| 2577 |
{ |
| 2578 |
PlayOnce, ///< Play the movie once, closing the movie controls at the end |
| 2579 |
PlayOpen, ///< Like PlayOnce, but leaving the controls open |
| 2580 |
PlayRepeat, ///< Play continuously until stopped |
| 2581 |
PlayPalindrome ///< Play forward, then backward, then again foward and so on until stopped |
| 2582 |
}; |
| 2583 |
|
| 2584 |
~MovieObject(); |
| 2585 |
|
| 2586 |
/** |
| 2587 |
The URL of the movie to be played |
| 2588 |
*/ |
| 2589 |
QString url() const; |
| 2590 |
|
| 2591 |
/** |
| 2592 |
The size of the movie |
| 2593 |
*/ |
| 2594 |
QSize size() const; |
| 2595 |
|
| 2596 |
/** |
| 2597 |
The rotation (either 0, 90, 180, or 270 degrees clockwise) for the movie, |
| 2598 |
*/ |
| 2599 |
int rotation() const; |
| 2600 |
|
| 2601 |
/** |
| 2602 |
Whether show a bar with movie controls |
| 2603 |
*/ |
| 2604 |
bool showControls() const; |
| 2605 |
|
| 2606 |
/** |
| 2607 |
How to play the movie |
| 2608 |
*/ |
| 2609 |
PlayMode playMode() const; |
| 2610 |
|
| 2611 |
/** |
| 2612 |
Returns whether a poster image should be shown if the movie is not playing. |
| 2613 |
\since 0.22 |
| 2614 |
*/ |
| 2615 |
bool showPosterImage() const; |
| 2616 |
|
| 2617 |
/** |
| 2618 |
Returns the poster image that should be shown if the movie is not playing. |
| 2619 |
If the image is null but showImagePoster() returns @c true, the first frame of the movie |
| 2620 |
should be used as poster image. |
| 2621 |
\since 0.22 |
| 2622 |
*/ |
| 2623 |
QImage posterImage() const; |
| 2624 |
|
| 2625 |
private: |
| 2626 |
/// \cond PRIVATE |
| 2627 |
explicit MovieObject(AnnotMovie *ann); |
| 2628 |
/// \endcond |
| 2629 |
|
| 2630 |
Q_DISABLE_COPY(MovieObject) |
| 2631 |
|
| 2632 |
MovieData *m_movieData; |
| 2633 |
}; |
| 2634 |
|
| 2635 |
} |
| 2636 |
|
| 2637 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags) |
| 2638 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::SearchFlags) |
| 2639 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints) |
| 2640 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions) |
| 2641 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions) |
| 2642 |
|
| 2643 |
#endif |