Poppler Qt5
0.74.0
|
#include <poppler-qt5.h>
Public Types | |
enum | FormType { NoForm, AcroForm, XfaForm } |
enum | PageLayout { NoLayout, SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight } |
enum | PageMode { UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttach } |
enum | RenderBackend { SplashBackend, ArthurBackend } |
enum | RenderHint { Antialiasing = 0x00000001, TextAntialiasing = 0x00000002, TextHinting = 0x00000004, TextSlightHinting = 0x00000008, OverprintPreview = 0x00000010, ThinLineSolid = 0x00000020, ThinLineShape = 0x00000040, IgnorePaperColor = 0x00000080, HideAnnotations = 0x00000100 } |
Public Member Functions | |
QString | author () const |
void * | colorDisplayProfile () const |
void * | colorRgbProfile () const |
QDateTime | creationDate () const |
QString | creator () const |
QDateTime | date (const QString &data) const |
QList< EmbeddedFile * > | embeddedFiles () const |
QByteArray | fontData (const FontInfo &font) const |
QList< FontInfo > | fonts () const |
QVector< int > | formCalculateOrder () const |
FormType | formType () const |
bool | getPdfId (QByteArray *permanentId, QByteArray *updateId) const |
void | getPdfVersion (int *major, int *minor) const |
bool | hasEmbeddedFiles () const |
bool | hasOptionalContent () const |
QString | info (const QString &data) const |
QStringList | infoKeys () const |
bool | isEncrypted () const |
bool | isLinearized () const |
bool | isLocked () const |
QString | keywords () const |
LinkDestination * | linkDestination (const QString &name) |
QString | metadata () const |
QDateTime | modificationDate () const |
FontIterator * | newFontIterator (int startPage=0) const |
int | numPages () const |
bool | okToAddNotes () const |
bool | okToAssemble () const |
bool | okToChange () const |
bool | okToCopy () const |
bool | okToCreateFormFields () const |
bool | okToExtractForAccessibility () const |
bool | okToFillForm () const |
bool | okToPrint () const |
bool | okToPrintHighRes () const |
OptContentModel * | optionalContentModel () |
QVector< OutlineItem > | outline () const |
Page * | page (int index) const |
Page * | page (const QString &label) const |
PageLayout | pageLayout () const |
PageMode | pageMode () const |
QColor | paperColor () const |
PDFConverter * | pdfConverter () const |
QString | producer () const |
PSConverter * | psConverter () const |
bool | removeInfo () |
RenderBackend | renderBackend () const |
RenderHints | renderHints () const |
QStringList | scripts () const |
bool | setAuthor (const QString &val) |
void | setColorDisplayProfile (void *outputProfileA) |
void | setColorDisplayProfileName (const QString &name) |
bool | setCreationDate (const QDateTime &val) |
bool | setCreator (const QString &val) |
bool | setDate (const QString &key, const QDateTime &val) |
bool | setInfo (const QString &key, const QString &val) |
bool | setKeywords (const QString &val) |
bool | setModificationDate (const QDateTime &val) |
void | setPaperColor (const QColor &color) |
bool | setProducer (const QString &val) |
void | setRenderBackend (RenderBackend backend) |
void | setRenderHint (RenderHint hint, bool on=true) |
bool | setSubject (const QString &val) |
bool | setTitle (const QString &val) |
QString | subject () const |
Qt::LayoutDirection | textDirection () const |
QString | title () const |
QDomDocument * | toc () const |
bool | unlock (const QByteArray &ownerPassword, const QByteArray &userPassword) |
~Document () | |
Static Public Member Functions | |
static QSet< RenderBackend > | availableRenderBackends () |
static Document * | load (const QString &filePath, const QByteArray &ownerPassword=QByteArray(), const QByteArray &userPassword=QByteArray()) |
static Document * | loadFromData (const QByteArray &fileContents, const QByteArray &ownerPassword=QByteArray(), const QByteArray &userPassword=QByteArray()) |
PDF document.
The Document class represents a PDF document: its pages, and all the global properties, metadata, etc.
All the functions that returns class pointers create new object, and the responsibility of those is given to the callee.
The only exception is Page::transition().
To get a Document, you have to load it via the load() & loadFromData() functions.
In all the functions that have passwords as arguments, they must be Latin1 encoded. If you have a password that is a UTF-8 string, you need to use QString::toLatin1() (or similar) to convert the password first. If you have a UTF-8 character array, consider converting it to a QString first (QString::fromUtf8(), or similar) before converting to Latin1 encoding.
To render pages of a document, you have different Document functions to set various options.
Poppler offers a different backends for rendering the pages. Currently there are two backends (see RenderBackend), but only the Splash engine works well and has been tested.
The available rendering backends can be discovered via availableRenderBackends(). The current rendering backend can be changed using setRenderBackend(). Please note that setting a backend not listed in the available ones will always result in null QImage's.
Poppler, if compiled with this support, provides functions to handle color profiles.
To know whether the Poppler version you are using has support for color management, you can query Poppler::isCmsAvailable(). In case it is not available, all the color management-related functions will either do nothing or return null.
Form types.
Enumerator | |
---|---|
NoForm | Document doesn't contain forms. |
AcroForm | AcroForm. |
XfaForm | Adobe XML Forms Architecture (XFA), currently unsupported. |
The page layout.
The page mode.
Enumerator | |
---|---|
UseNone | No mode - neither document outline nor thumbnail images are visible. |
UseOutlines | Document outline visible. |
UseThumbs | Thumbnail images visible. |
FullScreen | Fullscreen mode (no menubar, windows controls etc) |
UseOC | Optional content group panel visible. |
UseAttach | Attachments panel visible. |
The render hints available.
|
static |
The available rendering backends.
void* Poppler::Document::colorDisplayProfile | ( | ) | const |
Return the current display profile.
cmsHPROFILE
of the LCMS library.void* Poppler::Document::colorRgbProfile | ( | ) | const |
Return the current RGB profile.
cmsHPROFILE
of the LCMS library.QDateTime Poppler::Document::date | ( | const QString & | data | ) | const |
The date associated with the document You would use this method with something like: \code
QDateTime created = m_doc->date("CreationDate"); QDateTime modified = m_doc->date("ModDate");
The available dates are:
data | the type of date that is required |
QList<EmbeddedFile*> Poppler::Document::embeddedFiles | ( | ) | const |
The documents embedded within the PDF document.
QByteArray Poppler::Document::fontData | ( | const FontInfo & | font | ) | const |
The font data if the font is an embedded one.
QList<FontInfo> Poppler::Document::fonts | ( | ) | const |
The fonts within the PDF document.
This is a shorthand for getting all the fonts at once.
QVector<int> Poppler::Document::formCalculateOrder | ( | ) | const |
Returns the calculate order for forms (using their id)
FormType Poppler::Document::formType | ( | ) | const |
Returns the type of forms contained in the document.
bool Poppler::Document::getPdfId | ( | QByteArray * | permanentId, |
QByteArray * | updateId | ||
) | const |
The PDF identifiers.
permanentId | an optional pointer to a variable where store the permanent ID of the document |
updateId | an optional pointer to a variable where store the update ID of the document |
void Poppler::Document::getPdfVersion | ( | int * | major, |
int * | minor | ||
) | const |
The version of the PDF specification that the document conforms to.
major | an optional pointer to a variable where store the "major" number of the version |
minor | an optional pointer to a variable where store the "minor" number of the version |
bool Poppler::Document::hasOptionalContent | ( | ) | const |
Test whether this document has "optional content".
Optional content is used to optionally turn on (display) and turn off (not display) some elements of the document. The most common use of this is for layers in design applications, but it can be used for a range of things, such as not including some content in printing, and displaying content in the appropriate language.
QString Poppler::Document::info | ( | const QString & | data | ) | const |
Get specified information associated with the document You would use this method with something like: \code
QString title = m_doc->info("Title"); QString subject = m_doc->info("Subject");
In addition to Title
and Subject
, other information that may be available include Author
, Keywords
, Creator
and Producer
.
data | the information that is required |
bool Poppler::Document::isLinearized | ( | ) | const |
Test if the document is linearised.
In some cases, this is called "fast web view", since it is mostly an optimisation for viewing over the Web.
LinkDestination* Poppler::Document::linkDestination | ( | const QString & | name | ) |
Tries to resolve the named destination name
.
|
static |
Load the document from a file on disk.
filePath | the name (and path, if required) of the file to load |
ownerPassword | the Latin1-encoded owner password to use in loading the file |
userPassword | the Latin1-encoded user ("open") password to use in loading the file |
|
static |
Load the document from memory.
fileContents | the file contents. They are copied so there is no need to keep the byte array around for the full life time of the document. |
ownerPassword | the Latin1-encoded owner password to use in loading the file |
userPassword | the Latin1-encoded user ("open") password to use in loading the file |
QString Poppler::Document::metadata | ( | ) | const |
Gets the metadata stream contents.
FontIterator* Poppler::Document::newFontIterator | ( | int | startPage = 0 | ) | const |
Creates a new FontIterator object for font scanning.
The new iterator can be used for reading the font information of the document, reading page by page.
The caller is responsible for the returned object, ie it should freed it when no more useful.
startPage | the initial page from which start reading fonts |
bool Poppler::Document::okToAssemble | ( | ) | const |
Test if the permissions on the document allow it to be "assembled" - insertion, rotation and deletion of pages; or creation of bookmarks and thumbnail images.
bool Poppler::Document::okToChange | ( | ) | const |
Test if the permissions on the document allow it to be changed.
bool Poppler::Document::okToFillForm | ( | ) | const |
Test if the permissions on the document allow interactive form fields (including signature fields) to be completed.
OptContentModel* Poppler::Document::optionalContentModel | ( | ) |
Itemviews model for optional content.
The model is owned by the document.
QVector<OutlineItem> Poppler::Document::outline | ( | ) | const |
Gets the outline of the document.
Page* Poppler::Document::page | ( | int | index | ) | const |
Get a specified Page.
Note that this follows the PDF standard of being zero based - if you want the first page, then you need an index of zero.
The caller gets the ownership of the returned object.
index | the page number index |
Page* Poppler::Document::page | ( | const QString & | label | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The intent is that you can pass in a label like "ix"
and get the page with that label (which might be in the table of contents), or pass in "1"
and get the page that the user expects (which might not be the first page, if there is a title page and a table of contents).
label | the page label |
PageLayout Poppler::Document::pageLayout | ( | ) | const |
The layout that pages should be shown in when the document is first opened.
This basically describes how pages are shown relative to each other.
PageMode Poppler::Document::pageMode | ( | ) | const |
The type of mode that should be used by the application when the document is opened.
Note that while this is called page mode, it is really viewer application mode.
QColor Poppler::Document::paperColor | ( | ) | const |
The paper color.
The default color is white.
PDFConverter* Poppler::Document::pdfConverter | ( | ) | const |
Gets a new PDF converter for this document.
The caller gets the ownership of the returned converter.
PSConverter* Poppler::Document::psConverter | ( | ) | const |
Gets a new PS converter for this document.
The caller gets the ownership of the returned converter.
bool Poppler::Document::removeInfo | ( | ) |
Remove the document's Info dictionary.
RenderBackend Poppler::Document::renderBackend | ( | ) | const |
RenderHints Poppler::Document::renderHints | ( | ) | const |
The currently set render hints.
QStringList Poppler::Document::scripts | ( | ) | const |
Document-level JavaScript scripts.
Returns the list of document level JavaScript scripts to be always executed before any other script.
bool Poppler::Document::setAuthor | ( | const QString & | val | ) |
Set the author of the document to.
val |
void Poppler::Document::setColorDisplayProfile | ( | void * | outputProfileA | ) |
Set a color display profile for the current document.
outputProfileA | is a cmsHPROFILE of the LCMS library. |
void Poppler::Document::setColorDisplayProfileName | ( | const QString & | name | ) |
Set a color display profile for the current document.
name | is the name of the display profile to set. |
bool Poppler::Document::setCreationDate | ( | const QDateTime & | val | ) |
Set the creation date of the document to.
val |
bool Poppler::Document::setCreator | ( | const QString & | val | ) |
Set the creator of the document to.
val |
bool Poppler::Document::setDate | ( | const QString & | key, |
const QDateTime & | val | ||
) |
Set the Info dict date entry specified by.
key | to |
val |
bool Poppler::Document::setInfo | ( | const QString & | key, |
const QString & | val | ||
) |
Set the value of the document's Info dictionary entry specified by.
key | to |
val |
bool Poppler::Document::setKeywords | ( | const QString & | val | ) |
Set the keywords of the document to.
val |
bool Poppler::Document::setModificationDate | ( | const QDateTime & | val | ) |
Set the modification date of the document to.
val |
void Poppler::Document::setPaperColor | ( | const QColor & | color | ) |
Sets the paper color.
color | the new paper color |
bool Poppler::Document::setProducer | ( | const QString & | val | ) |
Set the producer of the document to.
val |
void Poppler::Document::setRenderBackend | ( | RenderBackend | backend | ) |
Sets the backend used to render the pages.
backend | the new rendering backend |
void Poppler::Document::setRenderHint | ( | RenderHint | hint, |
bool | on = true |
||
) |
Sets the render hint
.
on | whether the flag should be added or removed. |
bool Poppler::Document::setSubject | ( | const QString & | val | ) |
Set the subject of the document to.
val |
bool Poppler::Document::setTitle | ( | const QString & | val | ) |
Set the title of the document to.
val |
Qt::LayoutDirection Poppler::Document::textDirection | ( | ) | const |
The predominant reading order for text as supplied by the document's viewer preferences.
QDomDocument* Poppler::Document::toc | ( | ) | const |
Gets the table of contents (TOC) of the Document.
The caller is responsible for the returned object.
In the tree the tag name is the 'screen' name of the entry. A tag can have attributes. Here follows the list of tag attributes with meaning:
Resolving the final destination for each item can be done in the following way:
Note also that if 'ExternalFileName' is not emtpy, then the destination refers to that document (and not to the current one).
bool Poppler::Document::unlock | ( | const QByteArray & | ownerPassword, |
const QByteArray & | userPassword | ||
) |
Provide the passwords required to unlock the document.
ownerPassword | the Latin1-encoded owner password to use in loading the file |
userPassword | the Latin1-encoded user ("open") password to use in loading the file |