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