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>
4
* Copyright (C) 2005-2010, Albert Astals Cid <aacid@kde.org>
5
* Copyright (C) 2005, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de>
6
* Copyright (C) 2006-2010, Pino Toscano <pino@kde.org>
7
* Copyright (C) 2009 Shawn Rutledge <shawn.t.rutledge@gmail.com>
8
* Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
9
* Copyright (C) 2010 Matthias Fauconneau <matthias.fauconneau@gmail.com>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2, or (at your option)
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
26
#ifndef __POPPLER_QT_H__
27
#define __POPPLER_QT_H__
29
#include "poppler-annotation.h"
30
#include "poppler-link.h"
31
#include "poppler-optcontent.h"
32
#include "poppler-page-transition.h"
34
#include <QtCore/QByteArray>
35
#include <QtCore/QDateTime>
36
#include <QtCore/QSet>
37
#include <QtXml/QDomDocument>
38
#include "poppler-export.h"
45
The %Poppler Qt4 binding.
64
This function type is used for debugging & error output;
65
the first parameter is the actual message, the second is the unaltered
66
closure argument which was passed to the setDebugErrorFunction call.
70
typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/);
73
Set a new debug/error output function.
75
If not set, by default error and debug messages will be sent to the
76
Qt \p qDebug() function.
78
\param debugFunction the new debug function
79
\param closure user data which will be passes as-is to the debug function
83
POPPLER_QT4_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure);
86
Describes the physical location of text on a document page
88
This very simple class describes the physical location of text
89
on the page. It consists of
90
- a QString that contains the text
91
- a QRectF that gives a box that describes where on the page
94
class POPPLER_QT4_EXPORT TextBox {
98
The default constructor sets the \p text and the rectangle that
99
contains the text. Coordinated for the \p bBox are in points =
102
TextBox(const QString& text, const QRectF &bBox);
109
Returns the text of this text box
111
QString text() const;
114
Returns the position of the text, in point, i.e., 1/72 of
119
QRectF boundingBox() const;
122
Returns the pointer to the next text box, if there is one.
124
Otherwise, it returns a null pointer.
126
TextBox *nextWord() const;
129
Returns the bounding box of the \p i -th characted of the word.
131
QRectF charBoundingBox(int i) const;
134
Returns whether there is a space character after this text box
136
bool hasSpaceAfter() const;
139
Q_DISABLE_COPY(TextBox)
147
Container class for information about a font within a PDF
150
class POPPLER_QT4_EXPORT FontInfo {
151
friend class Document;
173
Create a new font information container.
178
Create a new font information container.
180
FontInfo( const FontInfoData &fid );
186
FontInfo( const FontInfo &fi );
194
The name of the font. Can be QString::null if the font has no name
196
QString name() const;
199
The path of the font file used to represent this font on this system,
200
or a null string is the font is embedded
202
QString file() const;
205
Whether the font is embedded in the file, or not
207
\return true if the font is embedded
209
bool isEmbedded() const;
212
Whether the font provided is only a subset of the full
213
font or not. This only has meaning if the font is embedded.
215
\return true if the font is only a subset
217
bool isSubset() const;
220
The type of font encoding
222
\return a enumerated value corresponding to the font encoding used
224
\sa typeName for a string equivalent
229
The name of the font encoding used
231
\note if you are looking for the name of the font (as opposed to the
232
encoding format used), you probably want name().
234
\sa type for a enumeration version
236
QString typeName() const;
239
Standard assignment operator
241
FontInfo& operator=( const FontInfo &fi );
244
FontInfoData *m_data;
248
class FontIteratorData;
250
Iterator for reading the fonts in a document.
252
FontIterator provides a Java-style iterator for reading the fonts in a
255
You can use it in the following way:
257
Poppler::FontIterator* it = doc->newFontIterator();
258
while (it->hasNext()) {
259
QList<Poppler::FontInfo> fonts = it->next();
260
// do something with the fonts
262
// after doing the job, the iterator must be freed
268
class POPPLER_QT4_EXPORT FontIterator {
269
friend class Document;
270
friend class DocumentData;
278
Returns the fonts of the current page and then advances the iterator
281
QList<FontInfo> next();
284
Checks whether there is at least one more page to iterate, ie returns
285
false when the iterator is beyond the last page.
287
bool hasNext() const;
290
Returns the current page where the iterator is.
292
int currentPage() const;
295
Q_DISABLE_COPY( FontIterator )
296
FontIterator( int, DocumentData *dd );
302
class EmbeddedFileData;
304
Container class for an embedded file with a PDF document
306
class POPPLER_QT4_EXPORT EmbeddedFile {
309
EmbeddedFile(EmbFile *embfile);
318
The name associated with the file
320
QString name() const;
323
The description associated with the file, if any.
325
This will return an empty QString if there is no description element
327
QString description() const;
330
The size of the file.
332
This will return < 0 if there is no size element
337
The modification date for the embedded file, if known.
339
QDateTime modDate() const;
342
The creation date for the embedded file, if known.
344
QDateTime createDate() const;
347
The MD5 checksum of the file.
349
This will return an empty QByteArray if there is no checksum element.
351
QByteArray checksum() const;
354
The MIME type of the file, if known.
358
QString mimeType() const;
361
The data as a byte array
366
Is the embedded file valid?
370
bool isValid() const;
373
A QDataStream for the actual data?
375
//QDataStream dataStream() const;
378
Q_DISABLE_COPY(EmbeddedFile)
380
EmbeddedFileData *m_embeddedFile;
385
\brief A page in a document.
387
The Page class represents a single page within a PDF document.
389
You cannot construct a Page directly, but you have to use the Document
390
functions that return a new Page out of an index or a label.
392
class POPPLER_QT4_EXPORT Page {
393
friend class Document;
401
The type of rotation to apply for an operation
403
enum Rotation { Rotate0 = 0, ///< Do not rotate
404
Rotate90 = 1, ///< Rotate 90 degrees clockwise
405
Rotate180 = 2, ///< Rotate 180 degrees
406
Rotate270 = 3 ///< Rotate 270 degrees clockwise (90 degrees counterclockwise)
410
The kinds of page actions
413
Opening, ///< The action when a page is "opened"
414
Closing ///< The action when a page is "closed"
418
How the text is going to be returned
422
PhysicalLayout, ///< The text is layouted to resemble the real page layout
423
RawOrderLayout ///< The text is returned without any type of processing
427
Additional flags for the renderToPainter method
432
Do not save/restore the caller-owned painter.
434
renderToPainter() by default preserves, using save() + restore(),
435
the state of the painter specified; if this is not needed, this
436
flag can avoid this job
438
DontSaveAndRestore = 0x00000001
440
Q_DECLARE_FLAGS( PainterFlags, PainterFlag )
443
Render the page to a QImage using the current
444
\link Document::renderBackend() Document renderer\endlink.
446
If \p x = \p y = \p w = \p h = -1, the method will automatically
447
compute the size of the image from the horizontal and vertical
448
resolutions specified in \p xres and \p yres. Otherwise, the
449
method renders only a part of the page, specified by the
450
parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned
451
QImage then has size (\p w, \p h), independent of the page
454
\param x specifies the left x-coordinate of the box, in
457
\param y specifies the top y-coordinate of the box, in
460
\param w specifies the width of the box, in pixels.
462
\param h specifies the height of the box, in pixels.
464
\param xres horizontal resolution of the graphics device,
467
\param yres vertical resolution of the graphics device, in
470
\param rotate how to rotate the page
472
\warning The parameter (\p x, \p y, \p w, \p h) are not
473
well-tested. Unusual or meaningless parameters may lead to
474
rather unexpected results.
476
\returns a QImage of the page, or a null image on failure.
480
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;
483
Render the page to the specified QPainter using the current
484
\link Document::renderBackend() Document renderer\endlink.
486
If \p x = \p y = \p w = \p h = -1, the method will automatically
487
compute the size of the page area from the horizontal and vertical
488
resolutions specified in \p xres and \p yres. Otherwise, the
489
method renders only a part of the page, specified by the
490
parameters (\p x, \p y, \p w, \p h) in pixel coordinates.
492
\param painter the painter to paint on
494
\param x specifies the left x-coordinate of the box, in
497
\param y specifies the top y-coordinate of the box, in
500
\param w specifies the width of the box, in pixels.
502
\param h specifies the height of the box, in pixels.
504
\param xres horizontal resolution of the graphics device,
507
\param yres vertical resolution of the graphics device, in
510
\param rotate how to rotate the page
512
\param flags additional painter flags
514
\warning The parameter (\p x, \p y, \p w, \p h) are not
515
well-tested. Unusual or meaningless parameters may lead to
516
rather unexpected results.
518
\returns whether the painting succeeded
520
\note This method is only supported for Arthur
524
bool renderToPainter(QPainter* painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1,
525
Rotation rotate = Rotate0, PainterFlags flags = 0) const;
528
Get the page thumbnail if it exists.
530
\return a QImage of the thumbnail, or a null image
531
if the PDF does not contain one for this page
535
QImage thumbnail() const;
538
Returns the text that is inside a specified rectangle
540
\param rect the rectangle specifying the area of interest,
541
with coordinates given in points, i.e., 1/72th of an inch.
542
If rect is null, all text on the page is given
546
QString text(const QRectF &rect, TextLayout textLayout) const;
549
Returns the text that is inside a specified rectangle.
550
The text is returned using the physical layout of the page
552
\param rect the rectangle specifying the area of interest,
553
with coordinates given in points, i.e., 1/72th of an inch.
554
If rect is null, all text on the page is given
556
QString text(const QRectF &rect) const;
559
The starting point for a search
561
enum SearchDirection { FromTop, ///< Start sorting at the top of the document
562
NextResult, ///< Find the next result, moving "down the page"
563
PreviousResult ///< Find the previous result, moving "up the page"
567
The type of search to perform
569
enum SearchMode { CaseSensitive, ///< Case differences cause no match in searching
570
CaseInsensitive ///< Case differences are ignored in matching
574
Returns true if the specified text was found.
576
\param text the text the search
577
\param rect in all directions is used to return where the text was found, for NextResult and PreviousResult
578
indicates where to continue searching for
579
\param direction in which direction do the search
580
\param caseSensitive be case sensitive?
581
\param rotate the rotation to apply for the search order
583
Q_DECL_DEPRECATED bool search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const;
586
Returns true if the specified text was found.
588
\param text the text the search
589
\param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult
590
indicates where to continue searching for
591
\param direction in which direction do the search
592
\param caseSensitive be case sensitive?
593
\param rotate the rotation to apply for the search order
596
bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const;
599
Returns a list of text of the page
601
This method returns a QList of TextBoxes that contain all
602
the text of the page, with roughly one text word of text
605
For text written in western languages (left-to-right and
606
up-to-down), the QList contains the text in the proper
609
\note The caller owns the text boxes and they should
610
be deleted when no longer required.
612
\warning This method is not tested with Asian scripts
614
QList<TextBox*> textList(Rotation rotate = Rotate0) const;
617
\return The dimensions (cropbox) of the page, in points (i.e. 1/72th on an inch)
619
QSizeF pageSizeF() const;
622
\return The dimensions (cropbox) of the page, in points (i.e. 1/72th on an inch)
624
QSize pageSize() const;
627
Returns the transition of this page
629
\returns a pointer to a PageTransition structure that
630
defines how transition to this page shall be performed.
632
\note The PageTransition structure is owned by this page, and will
633
automatically be destroyed when this page class is
636
PageTransition *transition() const;
639
Gets the page action specified, or NULL if there is no action.
643
Link *action( PageAction act ) const;
646
Types of orientations that are possible
649
Landscape, ///< Landscape orientation (portrait, with 90 degrees clockwise rotation )
650
Portrait, ///< Normal portrait orientation
651
Seascape, ///< Seascape orientation (portrait, with 270 degrees clockwise rotation)
652
UpsideDown ///< Upside down orientation (portrait, with 180 degrees rotation)
656
The orientation of the page
658
Orientation orientation() const;
663
void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown);
666
Gets the links of the page
668
QList<Link*> links() const;
671
Returns the annotations of the page
673
QList<Annotation*> annotations() const;
676
Returns the form fields on the page
680
QList<FormField*> formFields() const;
683
Returns the page duration. That is the time, in seconds, that the page
684
should be displayed before the presentation automatically advances to the next page.
685
Returns < 0 if duration is not set.
689
double duration() const;
692
Returns the label of the page, or a null string is the page has no label.
696
QString label() const;
701
Page(DocumentData *doc, int index);
708
The Document class represents a PDF document: its pages, and all the global
709
properties, metadata, etc.
711
\section ownership Ownership of the returned objects
713
All the functions that returns class pointers create new object, and the
714
responsability of those is given to the callee.
716
The only exception is \link Poppler::Page::transition() Page::transition()\endlink.
718
\section document-loading Loading
720
To get a Document, you have to load it via the load() & loadFromData()
723
In all the functions that have passwords as arguments, they \b must be Latin1
724
encoded. If you have a password that is a UTF-8 string, you need to use
725
QString::toLatin1() (or similar) to convert the password first.
726
If you have a UTF-8 character array, consider converting it to a QString first
727
(QString::fromUtf8(), or similar) before converting to Latin1 encoding.
729
\section document-rendering Rendering
731
To render pages of a document, you have different Document functions to set
734
\subsection document-rendering-backend Backends
736
%Poppler offers a different backends for rendering the pages. Currently
737
there are two backends (see #RenderBackend), but only the Splash engine works
738
well and has been tested.
740
The available rendering backends can be discovered via availableRenderBackends().
741
The current rendering backend can be changed using setRenderBackend().
742
Please note that setting a backend not listed in the available ones
743
will always result in null QImage's.
745
\section document-cms Color management support
747
%Poppler, if compiled with this support, provides functions to handle color
750
To know whether the %Poppler version you are using has support for color
751
management, you can query Poppler::isCmsAvailable(). In case it is not
752
avilable, all the color management-related functions will either do nothing
755
class POPPLER_QT4_EXPORT Document {
757
friend class DocumentData;
764
UseNone, ///< No mode - neither document outline nor thumbnail images are visible
765
UseOutlines, ///< Document outline visible
766
UseThumbs, ///< Thumbnail images visible
767
FullScreen, ///< Fullscreen mode (no menubar, windows controls etc)
768
UseOC, ///< Optional content group panel visible
769
UseAttach ///< Attachments panel visible
776
NoLayout, ///< Layout not specified
777
SinglePage, ///< Display a single page
778
OneColumn, ///< Display a single column of pages
779
TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left
780
TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right
781
TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left
782
TwoPageRight ///< Display the pages two at a time, with odd-numbered pages on the right
786
The render backends available
791
SplashBackend, ///< Splash backend
792
ArthurBackend ///< Arthur (Qt4) backend
796
The render hints available
801
Antialiasing = 0x00000001, ///< Antialiasing for graphics
802
TextAntialiasing = 0x00000002, ///< Antialiasing for text
803
TextHinting = 0x00000004 ///< Hinting for text \since 0.12.1
805
Q_DECLARE_FLAGS( RenderHints, RenderHint )
808
Set a color display profile for the current document.
810
\param outputProfileA is a \c cmsHPROFILE of the LCMS library.
814
void setColorDisplayProfile(void *outputProfileA);
816
Set a color display profile for the current document.
818
\param name is the name of the display profile to set.
822
void setColorDisplayProfileName(const QString &name);
824
Return the current RGB profile.
826
\return a \c cmsHPROFILE of the LCMS library.
830
void* colorRgbProfile() const;
832
Return the current display profile.
834
\return a \c cmsHPROFILE of the LCMS library.
838
void *colorDisplayProfile() const;
841
Load the document from a file on disk
843
\param filePath the name (and path, if required) of the file to load
844
\param ownerPassword the Latin1-encoded owner password to use in
846
\param userPassword the Latin1-encoded user ("open") password
847
to use in loading the file
849
\return the loaded document, or NULL on error
851
\note The caller owns the pointer to Document, and this should
852
be deleted when no longer required.
854
\warning The returning document may be locked if a password is required
855
to open the file, and one is not provided (as the userPassword).
857
static Document *load(const QString & filePath,
858
const QByteArray &ownerPassword=QByteArray(),
859
const QByteArray &userPassword=QByteArray());
862
Load the document from memory
864
\param fileContents the file contents. They are copied so there is no need
865
to keep the byte array around for the full life time of
867
\param ownerPassword the Latin1-encoded owner password to use in
869
\param userPassword the Latin1-encoded user ("open") password
870
to use in loading the file
872
\return the loaded document, or NULL on error
874
\note The caller owns the pointer to Document, and this should
875
be deleted when no longer required.
877
\warning The returning document may be locked if a password is required
878
to open the file, and one is not provided (as the userPassword).
882
static Document *loadFromData(const QByteArray &fileContents,
883
const QByteArray &ownerPassword=QByteArray(),
884
const QByteArray &userPassword=QByteArray());
889
Note that this follows the PDF standard of being zero based - if you
890
want the first page, then you need an index of zero.
892
The caller gets the ownership of the returned object.
894
\param index the page number index
896
Page *page(int index) const;
902
The intent is that you can pass in a label like \c "ix" and
903
get the page with that label (which might be in the table of
904
contents), or pass in \c "1" and get the page that the user
905
expects (which might not be the first page, if there is a
906
title page and a table of contents).
908
\param label the page label
910
Page *page(const QString &label) const;
913
The number of pages in the document
915
int numPages() const;
918
The type of mode that should be used by the application
919
when the document is opened. Note that while this is
920
called page mode, it is really viewer application mode.
922
PageMode pageMode() const;
925
The layout that pages should be shown in when the document
926
is first opened. This basically describes how pages are
927
shown relative to each other.
929
PageLayout pageLayout() const;
932
Provide the passwords required to unlock the document
934
\param ownerPassword the Latin1-encoded owner password to use in
936
\param userPassword the Latin1-encoded user ("open") password
937
to use in loading the file
939
bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword);
942
Determine if the document is locked
944
bool isLocked() const;
947
The date associated with the document
949
You would use this method with something like:
951
QDateTime created = m_doc->date("CreationDate");
952
QDateTime modified = m_doc->date("ModDate");
955
The available dates are:
956
- CreationDate: the date of creation of the document
957
- ModDate: the date of the last change in the document
959
\param data the type of date that is required
961
QDateTime date( const QString & data ) const;
964
Get specified information associated with the document
966
You would use this method with something like:
968
QString title = m_doc->info("Title");
969
QString subject = m_doc->info("Subject");
972
In addition to \c Title and \c Subject, other information that may
973
be available include \c Author, \c Keywords, \c Creator and \c Producer.
975
\param data the information that is required
977
\sa infoKeys() to get a list of the available keys
979
QString info( const QString & data ) const;
982
Obtain a list of the available string information keys.
984
QStringList infoKeys() const;
987
Test if the document is encrypted
989
bool isEncrypted() const;
992
Test if the document is linearised
994
In some cases, this is called "fast web view", since it
995
is mostly an optimisation for viewing over the Web.
997
bool isLinearized() const;
1000
Test if the permissions on the document allow it to be
1003
bool okToPrint() const;
1006
Test if the permissions on the document allow it to be
1007
printed at high resolution
1009
bool okToPrintHighRes() const;
1012
Test if the permissions on the document allow it to be
1015
\note depending on the type of change, it may be more
1016
appropriate to check other properties as well.
1018
bool okToChange() const;
1021
Test if the permissions on the document allow the
1022
contents to be copied / extracted
1024
bool okToCopy() const;
1027
Test if the permissions on the document allow annotations
1028
to be added or modified, and interactive form fields (including
1029
signature fields) to be completed.
1031
bool okToAddNotes() const;
1034
Test if the permissions on the document allow interactive
1035
form fields (including signature fields) to be completed.
1037
\note this can be true even if okToAddNotes() is false - this
1038
means that only form completion is permitted.
1040
bool okToFillForm() const;
1043
Test if the permissions on the document allow interactive
1044
form fields (including signature fields) to be set, created and
1047
bool okToCreateFormFields() const;
1050
Test if the permissions on the document allow content extraction
1051
(text and perhaps other content) for accessibility usage (eg for
1054
bool okToExtractForAccessibility() const;
1057
Test if the permissions on the document allow it to be
1058
"assembled" - insertion, rotation and deletion of pages;
1059
or creation of bookmarks and thumbnail images.
1061
\note this can be true even if okToChange() is false
1063
bool okToAssemble() const;
1066
The version of the PDF specification that the document
1069
\deprecated use getPdfVersion and avoid float point
1070
comparisons/handling
1072
Q_DECL_DEPRECATED double pdfVersion() const;
1075
The version of the PDF specification that the document
1078
\param major an optional pointer to a variable where store the
1079
"major" number of the version
1080
\param minor an optional pointer to a variable where store the
1081
"minor" number of the version
1085
void getPdfVersion(int *major, int *minor) const;
1088
The fonts within the PDF document.
1090
This is a shorthand for getting all the fonts at once.
1092
\note this can take a very long time to run with a large
1093
document. You may wish to use a FontIterator if you have more
1096
\see newFontIterator()
1098
QList<FontInfo> fonts() const;
1101
Scans for fonts within the PDF document.
1103
\param numPages the number of pages to scan
1104
\param fontList pointer to the list where the font information
1107
\note with this method you can scan for fonts only \em once for each
1108
document; once the end is reached, no more scanning with this method
1111
\return false if the end of the document has been reached
1113
\deprecated this function is quite limited in its job (see note),
1114
better use fonts() or newFontIterator()
1116
\see fonts(), newFontIterator()
1118
Q_DECL_DEPRECATED bool scanForFonts( int numPages, QList<FontInfo> *fontList ) const;
1121
Creates a new FontIterator object for font scanning.
1123
The new iterator can be used for reading the font information of the
1124
document, reading page by page.
1126
The caller is responsible for the returned object, ie it should freed
1127
it when no more useful.
1129
\param startPage the initial page from which start reading fonts
1135
FontIterator* newFontIterator( int startPage = 0 ) const;
1138
The font data if the font is an embedded one.
1142
QByteArray fontData(const FontInfo &font) const;
1145
The documents embedded within the PDF document.
1147
\note there are two types of embedded document - this call
1148
only accesses documents that are embedded at the document level.
1150
QList<EmbeddedFile*> embeddedFiles() const;
1153
Whether there are any documents embedded in this PDF document.
1155
bool hasEmbeddedFiles() const;
1158
Gets the table of contents (TOC) of the Document.
1160
The caller is responsable for the returned object.
1162
In the tree the tag name is the 'screen' name of the entry. A tag can have
1163
attributes. Here follows the list of tag attributes with meaning:
1164
- Destination: A string description of the referred destination
1165
- DestinationName: A 'named reference' to the viewport
1166
- ExternalFileName: A link to a external filename
1167
- Open: A bool value that tells whether the subbranch of the item is open or not
1169
Resolving the final destination for each item can be done in the following way:
1170
- first, checking for 'Destination': if not empty, then a LinkDestination
1171
can be constructed straight with it
1172
- as second step, if the 'DestinationName' is not empty, then the destination
1173
can be resolved using linkDestination()
1175
Note also that if 'ExternalFileName' is not emtpy, then the destination refers
1176
to that document (and not to the current one).
1178
\returns the TOC, or NULL if the Document does not have one
1180
QDomDocument *toc() const;
1183
Tries to resolve the named destination \p name.
1185
\note this operation starts a search through the whole document
1187
\returns a new LinkDestination object if the named destination was
1188
actually found, or NULL otherwise
1190
LinkDestination *linkDestination( const QString &name );
1193
Sets the paper color
1195
\param color the new paper color
1197
void setPaperColor(const QColor &color);
1201
The default color is white.
1203
QColor paperColor() const;
1206
Sets the backend used to render the pages.
1208
\param backend the new rendering backend
1212
void setRenderBackend( RenderBackend backend );
1214
The currently set render backend
1216
The default backend is \ref SplashBackend
1220
RenderBackend renderBackend() const;
1223
The available rendering backends.
1227
static QSet<RenderBackend> availableRenderBackends();
1230
Sets the render \p hint .
1232
\note some hints may not be supported by some rendering backends.
1234
\param on whether the flag should be added or removed.
1238
void setRenderHint( RenderHint hint, bool on = true );
1240
The currently set render hints.
1244
RenderHints renderHints() const;
1247
Gets a new PS converter for this document.
1249
The caller gets the ownership of the returned converter.
1253
PSConverter *psConverter() const;
1256
Gets a new PDF converter for this document.
1258
The caller gets the ownership of the returned converter.
1262
PDFConverter *pdfConverter() const;
1265
Gets the metadata stream contents
1269
QString metadata() const;
1272
Test whether this document has "optional content".
1274
Optional content is used to optionally turn on (display)
1275
and turn off (not display) some elements of the document.
1276
The most common use of this is for layers in design
1277
applications, but it can be used for a range of things,
1278
such as not including some content in printing, and
1279
displaying content in the appropriate language.
1283
bool hasOptionalContent() const;
1286
Itemviews model for optional content.
1288
The model is owned by the document.
1292
OptContentModel *optionalContentModel();
1295
Document-level JavaScript scripts.
1297
Returns the list of document level JavaScript scripts to be always
1298
executed before any other script.
1302
QStringList scripts() const;
1305
The PDF identifiers.
1307
\param permanentId an optional pointer to a variable where store the
1308
permanent ID of the document
1309
\param updateId an optional pointer to a variable where store the
1310
update ID of the document
1312
\return whether the document has the IDs
1316
bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const;
1324
Q_DISABLE_COPY(Document)
1326
DocumentData *m_doc;
1328
Document(DocumentData *dataA);
1331
class BaseConverterPrivate;
1332
class PSConverterPrivate;
1333
class PDFConverterPrivate;
1335
\brief Base converter.
1337
This is the base class for the converters.
1341
class POPPLER_QT4_EXPORT BaseConverter
1343
friend class Document;
1348
virtual ~BaseConverter();
1350
/** Sets the output file name. You must set this or the output device. */
1351
void setOutputFileName(const QString &outputFileName);
1354
* Sets the output device. You must set this or the output file name.
1358
void setOutputDevice(QIODevice *device);
1361
Does the conversion.
1363
\return whether the conversion succeeded
1365
virtual bool convert() = 0;
1372
NotSupportedInputFileError
1376
Returns the last error
1379
Error lastError() const;
1383
BaseConverter(BaseConverterPrivate &dd);
1384
Q_DECLARE_PRIVATE(BaseConverter)
1385
BaseConverterPrivate *d_ptr;
1389
Q_DISABLE_COPY(BaseConverter)
1393
Converts a PDF to PS
1395
Sizes have to be in Points (1/72 inch)
1397
If you are using QPrinter you can get paper size by doing:
1399
QPrinter dummy(QPrinter::PrinterResolution);
1400
dummy.setFullPage(true);
1401
dummy.setPageSize(myPageSize);
1402
width = dummy.width();
1403
height = dummy.height();
1408
class POPPLER_QT4_EXPORT PSConverter : public BaseConverter
1410
friend class Document;
1413
Options for the PS export.
1418
Printing = 0x00000001, ///< The PS is generated for priting purpouses
1419
StrictMargins = 0x00000002,
1420
ForceRasterization = 0x00000004
1422
Q_DECLARE_FLAGS( PSOptions, PSOption )
1429
/** Sets the list of pages to print. Mandatory. */
1430
void setPageList(const QList<int> &pageList);
1433
Sets the title of the PS Document. Optional
1435
void setTitle(const QString &title);
1438
Sets the horizontal DPI. Defaults to 72.0
1440
void setHDPI(double hDPI);
1443
Sets the vertical DPI. Defaults to 72.0
1445
void setVDPI(double vDPI);
1448
Sets the rotate. Defaults to not rotated
1450
void setRotate(int rotate);
1453
Sets the output paper width. Has to be set.
1455
void setPaperWidth(int paperWidth);
1458
Sets the output paper height. Has to be set.
1460
void setPaperHeight(int paperHeight);
1463
Sets the output right margin. Defaults to 0
1465
void setRightMargin(int marginRight);
1468
Sets the output bottom margin. Defaults to 0
1470
void setBottomMargin(int marginBottom);
1473
Sets the output left margin. Defaults to 0
1475
void setLeftMargin(int marginLeft);
1478
Sets the output top margin. Defaults to 0
1480
void setTopMargin(int marginTop);
1483
Defines if margins have to be strictly followed (even if that
1484
means changing aspect ratio), or if the margins can be adapted
1485
to keep aspect ratio.
1489
void setStrictMargins(bool strictMargins);
1491
/** Defines if the page will be rasterized to an image before printing. Defaults to false */
1492
void setForceRasterize(bool forceRasterize);
1495
Sets the options for the PS export.
1499
void setPSOptions(PSOptions options);
1502
The currently set options for the PS export.
1504
The default flags are: Printing.
1508
PSOptions psOptions() const;
1511
Sets a function that will be called each time a page is converted.
1513
The payload belongs to the caller.
1517
void setPageConvertedCallback(void (* callback)(int page, void *payload), void *payload);
1522
Q_DECLARE_PRIVATE(PSConverter)
1523
Q_DISABLE_COPY(PSConverter)
1525
PSConverter(DocumentData *document);
1529
Converts a PDF to PDF (thus saves a copy of the document).
1533
class POPPLER_QT4_EXPORT PDFConverter : public BaseConverter
1535
friend class Document;
1538
Options for the PDF export.
1541
WithChanges = 0x00000001 ///< The changes done to the document are saved as well
1543
Q_DECLARE_FLAGS( PDFOptions, PDFOption )
1548
virtual ~PDFConverter();
1551
Sets the options for the PDF export.
1553
void setPDFOptions(PDFOptions options);
1555
The currently set options for the PDF export.
1557
PDFOptions pdfOptions() const;
1562
Q_DECLARE_PRIVATE(PDFConverter)
1563
Q_DISABLE_COPY(PDFConverter)
1565
PDFConverter(DocumentData *document);
1569
Conversion from PDF date string format to QDateTime
1571
POPPLER_QT4_EXPORT QDateTime convertDate( char *dateString );
1574
Whether the color management functions are available.
1578
POPPLER_QT4_EXPORT bool isCmsAvailable();
1582
Container class for a sound file in a PDF document.
1584
A sound can be either External (in that case should be loaded the file
1585
whose url is represented by url() ), or Embedded, and the player has to
1586
play the data contained in data().
1590
class POPPLER_QT4_EXPORT SoundObject {
1596
External, ///< The real sound file is external
1597
Embedded ///< The sound is contained in the data
1601
The encoding format used for the sound
1603
enum SoundEncoding {
1604
Raw, ///< Raw encoding, with unspecified or unsigned values in the range [ 0, 2^B - 1 ]
1605
Signed, ///< Twos-complement values
1606
muLaw, ///< mu-law-encoded samples
1607
ALaw ///< A-law-encoded samples
1611
SoundObject(Sound *popplersound);
1617
Is the sound embedded (SoundObject::Embedded) or external (SoundObject::External)?
1619
SoundType soundType() const;
1622
The URL of the sound file to be played, in case of SoundObject::External
1624
QString url() const;
1627
The data of the sound, in case of SoundObject::Embedded
1629
QByteArray data() const;
1632
The sampling rate of the sound
1634
double samplingRate() const;
1637
The number of sound channels to use to play the sound
1639
int channels() const;
1642
The number of bits per sample value per channel
1644
int bitsPerSample() const;
1647
The encoding used for the sound
1649
SoundEncoding soundEncoding() const;
1652
Q_DISABLE_COPY(SoundObject)
1654
SoundData *m_soundData;
1659
Container class for a movie object in a PDF document.
1663
class POPPLER_QT4_EXPORT MovieObject {
1667
The play mode for playing the movie
1670
PlayOnce, ///< Play the movie once, closing the movie controls at the end
1671
PlayOpen, ///< Like PlayOnce, but leaving the controls open
1672
PlayRepeat, ///< Play continuously until stopped
1673
PlayPalindrome ///< Play forward, then backward, then again foward and so on until stopped
1679
The URL of the movie to be played
1681
QString url() const;
1684
The size of the movie
1689
The rotation (either 0, 90, 180, or 270 degrees clockwise) for the movie,
1691
int rotation() const;
1694
Whether show a bar with movie controls
1696
bool showControls() const;
1699
How to play the movie
1701
PlayMode playMode() const;
1705
MovieObject( AnnotMovie *ann );
1708
Q_DISABLE_COPY(MovieObject)
1710
MovieData *m_movieData;
1715
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags)
1716
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints)
1717
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions)
1718
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions)