Poppler Qt5 24.11.0
Public Types | Public Member Functions | List of all members
Poppler::Page Class Reference

#include <poppler-qt5.h>

Public Types

enum  Orientation { Landscape , Portrait , Seascape , UpsideDown }
 
enum  PageAction { Opening , Closing }
 
enum  PainterFlag { NoPainterFlags = 0x00000000 , DontSaveAndRestore = 0x00000001 }
 
using RenderToImagePartialUpdateFunc = void(*)(const QImage &, const QVariant &)
 
enum  Rotation { Rotate0 = 0 , Rotate90 = 1 , Rotate180 = 2 , Rotate270 = 3 }
 
enum  SearchDirection { FromTop , NextResult , PreviousResult }
 
enum  SearchFlag {
  NoSearchFlags = 0x00000000 , IgnoreCase = 0x00000001 , WholeWords = 0x00000002 , IgnoreDiacritics = 0x00000004 ,
  AcrossLines = 0x00000008
}
 
enum  SearchMode { CaseSensitive , CaseInsensitive }
 
using ShouldAbortQueryFunc = bool(*)(const QVariant &)
 
using ShouldRenderToImagePartialQueryFunc = bool(*)(const QVariant &)
 
enum  TextLayout { PhysicalLayout , RawOrderLayout }
 

Public Member Functions

Linkaction (PageAction act) const
 
void addAnnotation (const Annotation *ann)
 
QList< Annotation * > annotations () const
 
QList< Annotation * > annotations (const QSet< Annotation::SubType > &subtypes) const
 
void defaultCTM (double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown)
 
double duration () const
 
QList< FormField * > formFields () const
 
int index () const
 
QString label () const
 
QList< Link * > links () const
 
Orientation orientation () const
 
QSize pageSize () const
 
QSizeF pageSizeF () const
 
void removeAnnotation (const Annotation *ann)
 
QImage renderToImage (double xres, double yres, int x, int y, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, const QVariant &payload) const
 
QImage renderToImage (double xres, double yres, int x, int y, int w, int h, Rotation rotate, RenderToImagePartialUpdateFunc partialUpdateCallback, ShouldRenderToImagePartialQueryFunc shouldDoPartialUpdateCallback, ShouldAbortQueryFunc shouldAbortRenderCallback, const QVariant &payload) const
 
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
 
bool renderToPainter (QPainter *painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate=Rotate0, PainterFlags flags=NoPainterFlags) const
 
bool search (const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate=Rotate0) const
 
bool search (const QString &text, double &sLeft, double &sTop, double &sRight, double &sBottom, SearchDirection direction, SearchFlags flags=NoSearchFlags, Rotation rotate=Rotate0) const
 
QList< QRectF > search (const QString &text, SearchFlags flags=NoSearchFlags, Rotation rotate=Rotate0) const
 
QList< QRectF > search (const QString &text, SearchMode caseSensitive, Rotation rotate=Rotate0) const
 
QString text (const QRectF &rect) const
 
QString text (const QRectF &rect, TextLayout textLayout) const
 
QList< TextBox * > textList (Rotation rotate, ShouldAbortQueryFunc shouldAbortExtractionCallback, const QVariant &closure) const
 
QList< TextBox * > textList (Rotation rotate=Rotate0) const
 
QImage thumbnail () const
 
PageTransitiontransition () const
 
 ~Page ()
 

Detailed Description

A page in a document.

The Page class represents a single page within a PDF document.

You cannot construct a Page directly, but you have to use the Document functions that return a new Page out of an index or a label.

Member Typedef Documentation

◆ RenderToImagePartialUpdateFunc

using Poppler::Page::RenderToImagePartialUpdateFunc = void (*)(const QImage & , const QVariant & )

Partial Update renderToImage callback.

This function type is used for doing partial rendering updates; the first parameter is the image as rendered up to now, the second is the unaltered closure argument which was passed to the renderToImage call.

Since
0.62

◆ ShouldAbortQueryFunc

using Poppler::Page::ShouldAbortQueryFunc = bool (*)(const QVariant & )

Abort query function callback.

This function type is used for query if the current rendering/text extraction should be cancelled.

Since
0.63

◆ ShouldRenderToImagePartialQueryFunc

using Poppler::Page::ShouldRenderToImagePartialQueryFunc = bool (*)(const QVariant & )

Partial Update query renderToImage callback.

This function type is used for query if the partial rendering update should happen; the parameter is the unaltered closure argument which was passed to the renderToImage call.

Since
0.62

Member Enumeration Documentation

◆ Orientation

Types of orientations that are possible.

Enumerator
Landscape 

Landscape orientation (portrait, with 90 degrees clockwise rotation )

Portrait 

Normal portrait orientation.

Seascape 

Seascape orientation (portrait, with 270 degrees clockwise rotation)

UpsideDown 

Upside down orientation (portrait, with 180 degrees rotation)

◆ PageAction

The kinds of page actions.

Enumerator
Opening 

The action when a page is "opened".

Closing 

The action when a page is "closed".

◆ PainterFlag

Additional flags for the renderToPainter method.

Since
0.16
Enumerator
NoPainterFlags 
Since
0.63
DontSaveAndRestore 

Do not save/restore the caller-owned painter.

renderToPainter() by default preserves, using save() + restore(), the state of the painter specified; if this is not needed, this flag can avoid this job

◆ Rotation

The type of rotation to apply for an operation.

Enumerator
Rotate0 

Do not rotate.

Rotate90 

Rotate 90 degrees clockwise.

Rotate180 

Rotate 180 degrees.

Rotate270 

Rotate 270 degrees clockwise (90 degrees counterclockwise)

◆ SearchDirection

The starting point for a search.

Enumerator
FromTop 

Start sorting at the top of the document.

NextResult 

Find the next result, moving "down the page".

PreviousResult 

Find the previous result, moving "up the page".

◆ SearchFlag

Flags to modify the search behaviour.

Since
0.31
Enumerator
NoSearchFlags 

since 0.63

IgnoreCase 

Case differences are ignored.

WholeWords 

Only whole words are matched.

IgnoreDiacritics 

Diacritic differences (eg.

accents, umlauts, diaeresis) are ignored.

Since
0.73 This option will have no effect if the search term contains characters which are not pure ascii.
AcrossLines 

Allows to match on text spanning from end of a line to the next line.

It won't match on text spanning more than two lines. Automatically ignores hyphen at end of line, and allows whitespace in search term to match on newline.

Since
21.05.0

◆ SearchMode

The type of search to perform.

Enumerator
CaseSensitive 

Case differences cause no match in searching.

CaseInsensitive 

Case differences are ignored in matching.

◆ TextLayout

How the text is going to be returned.

Since
0.16
Enumerator
PhysicalLayout 

The text is layouted to resemble the real page layout.

RawOrderLayout 

The text is returned without any type of processing.

Member Function Documentation

◆ action()

Link * Poppler::Page::action ( PageAction  act) const

Gets the page action specified, or NULL if there is no action.

Since
0.6

◆ addAnnotation()

void Poppler::Page::addAnnotation ( const Annotation ann)

Adds an annotation to the page.

Note
Ownership of the annotation object stays with the caller, who can delete it at any time.
Since
0.20

◆ annotations() [1/2]

QList< Annotation * > Poppler::Page::annotations ( ) const

Returns the annotations of the page.

Note
If you call this method twice, you get different objects pointing to the same annotations (see Annotation). The caller owns the returned objects and they should be deleted when no longer required.

◆ annotations() [2/2]

QList< Annotation * > Poppler::Page::annotations ( const QSet< Annotation::SubType > &  subtypes) const

Returns the annotations of the page.

Parameters
subtypesthe subtypes of annotations you are interested in
Note
If you call this method twice, you get different objects pointing to the same annotations (see Annotation). The caller owns the returned objects and they should be deleted when no longer required.
Since
0.28

◆ duration()

double Poppler::Page::duration ( ) const

Returns the page duration.

That is the time, in seconds, that the page should be displayed before the presentation automatically advances to the next page. Returns < 0 if duration is not set.

Since
0.6

◆ formFields()

QList< FormField * > Poppler::Page::formFields ( ) const

Returns the form fields on the page The caller gets the ownership of the returned objects.

Since
0.6

◆ index()

int Poppler::Page::index ( ) const

Returns the index of the page.

Since
0.70

◆ label()

QString Poppler::Page::label ( ) const

Returns the label of the page, or a null string is the page has no label.

Since
0.6

◆ pageSize()

QSize Poppler::Page::pageSize ( ) const
Returns
The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch)

◆ pageSizeF()

QSizeF Poppler::Page::pageSizeF ( ) const
Returns
The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch)

◆ removeAnnotation()

void Poppler::Page::removeAnnotation ( const Annotation ann)

Removes an annotation from the page and destroys the annotation object.

Note
There mustn't be other Annotation objects pointing this annotation
Since
0.20

◆ renderToImage() [1/3]

QImage Poppler::Page::renderToImage ( double  xres,
double  yres,
int  x,
int  y,
int  w,
int  h,
Rotation  rotate,
RenderToImagePartialUpdateFunc  partialUpdateCallback,
ShouldRenderToImagePartialQueryFunc  shouldDoPartialUpdateCallback,
const QVariant &  payload 
) const

Render the page to a QImage using the current Document renderer.

If x = y = w = h = -1, the method will automatically compute the size of the image from the horizontal and vertical resolutions specified in xres and yres. Otherwise, the method renders only a part of the page, specified by the parameters (x, y, w, h) in pixel coordinates. The returned QImage then has size (w, h), independent of the page size.

Parameters
xspecifies the left x-coordinate of the box, in pixels.
yspecifies the top y-coordinate of the box, in pixels.
wspecifies the width of the box, in pixels.
hspecifies the height of the box, in pixels.
xreshorizontal resolution of the graphics device, in dots per inch
yresvertical resolution of the graphics device, in dots per inch
rotatehow to rotate the page
partialUpdateCallbackcallback that will be called to report a partial rendering update
shouldDoPartialUpdateCallbackcallback that will be called to ask if a partial rendering update is wanted. This exists because doing a partial rendering update needs to copy the image buffer so if it is not wanted it is better skipped early.
payloadopaque structure that will be passed back to partialUpdateCallback and shouldDoPartialUpdateCallback.
Warning
The parameter (x, y, w, h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results.
Returns
a QImage of the page, or a null image on failure.
Since
0.62

◆ renderToImage() [2/3]

QImage Poppler::Page::renderToImage ( double  xres,
double  yres,
int  x,
int  y,
int  w,
int  h,
Rotation  rotate,
RenderToImagePartialUpdateFunc  partialUpdateCallback,
ShouldRenderToImagePartialQueryFunc  shouldDoPartialUpdateCallback,
ShouldAbortQueryFunc  shouldAbortRenderCallback,
const QVariant &  payload 
) const

Render the page to a QImage using the current Document renderer.

If x = y = w = h = -1, the method will automatically compute the size of the image from the horizontal and vertical resolutions specified in xres and yres. Otherwise, the method renders only a part of the page, specified by the parameters (x, y, w, h) in pixel coordinates. The returned QImage then has size (w, h), independent of the page size.

Parameters
xspecifies the left x-coordinate of the box, in pixels.
yspecifies the top y-coordinate of the box, in pixels.
wspecifies the width of the box, in pixels.
hspecifies the height of the box, in pixels.
xreshorizontal resolution of the graphics device, in dots per inch
yresvertical resolution of the graphics device, in dots per inch
rotatehow to rotate the page
partialUpdateCallbackcallback that will be called to report a partial rendering update
shouldDoPartialUpdateCallbackcallback that will be called to ask if a partial rendering update is wanted. This exists because doing a partial rendering update needs to copy the image buffer so if it is not wanted it is better skipped early.
shouldAbortRenderCallbackcallback that will be called to ask if the rendering should be cancelled.
payloadopaque structure that will be passed back to partialUpdateCallback, shouldDoPartialUpdateCallback and shouldAbortRenderCallback.
Warning
The parameter (x, y, w, h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results.
Returns
a QImage of the page, or a null image on failure.
Since
0.63

◆ renderToImage() [3/3]

QImage Poppler::Page::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

Render the page to a QImage using the current Document renderer.

If x = y = w = h = -1, the method will automatically compute the size of the image from the horizontal and vertical resolutions specified in xres and yres. Otherwise, the method renders only a part of the page, specified by the parameters (x, y, w, h) in pixel coordinates. The returned QImage then has size (w, h), independent of the page size.

Parameters
xspecifies the left x-coordinate of the box, in pixels.
yspecifies the top y-coordinate of the box, in pixels.
wspecifies the width of the box, in pixels.
hspecifies the height of the box, in pixels.
xreshorizontal resolution of the graphics device, in dots per inch
yresvertical resolution of the graphics device, in dots per inch
rotatehow to rotate the page
Warning
The parameter (x, y, w, h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results.
Returns
a QImage of the page, or a null image on failure.
Since
0.6

◆ renderToPainter()

bool Poppler::Page::renderToPainter ( QPainter *  painter,
double  xres = 72.0,
double  yres = 72.0,
int  x = -1,
int  y = -1,
int  w = -1,
int  h = -1,
Rotation  rotate = Rotate0,
PainterFlags  flags = NoPainterFlags 
) const

Render the page to the specified QPainter using the current Document renderer.

If x = y = w = h = -1, the method will automatically compute the size of the page area from the horizontal and vertical resolutions specified in xres and yres. Otherwise, the method renders only a part of the page, specified by the parameters (x, y, w, h) in pixel coordinates.

Parameters
painterthe painter to paint on
xspecifies the left x-coordinate of the box, in pixels.
yspecifies the top y-coordinate of the box, in pixels.
wspecifies the width of the box, in pixels.
hspecifies the height of the box, in pixels.
xreshorizontal resolution of the graphics device, in dots per inch
yresvertical resolution of the graphics device, in dots per inch
rotatehow to rotate the page
flagsadditional painter flags
Warning
The parameter (x, y, w, h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results.
Returns
whether the painting succeeded
Note
This method is only supported for the QPainterOutputDev
Since
0.16

◆ search() [1/4]

bool Poppler::Page::search ( const QString &  text,
double &  rectLeft,
double &  rectTop,
double &  rectRight,
double &  rectBottom,
SearchDirection  direction,
SearchMode  caseSensitive,
Rotation  rotate = Rotate0 
) const

Returns true if the specified text was found.

Parameters
textthe text the search
rectXXXin all directions is used to return where the text was found, for NextResult and PreviousResult indicates where to continue searching for
directionin which direction do the search
caseSensitivebe case sensitive?
rotatethe rotation to apply for the search order
Since
0.14

◆ search() [2/4]

bool Poppler::Page::search ( const QString &  text,
double &  sLeft,
double &  sTop,
double &  sRight,
double &  sBottom,
SearchDirection  direction,
SearchFlags  flags = NoSearchFlags,
Rotation  rotate = Rotate0 
) const

Returns true if the specified text was found.

Parameters
textthe text the search
rectXXXin all directions is used to return where the text was found, for NextResult and PreviousResult indicates where to continue searching for
directionin which direction do the search
flagsthe flags to consider during matching
rotatethe rotation to apply for the search order
Since
0.31

◆ search() [3/4]

QList< QRectF > Poppler::Page::search ( const QString &  text,
SearchFlags  flags = NoSearchFlags,
Rotation  rotate = Rotate0 
) const

Returns a list of all occurrences of the specified text on the page.

if SearchFlags::AcrossLines is given in

Parameters
flags,thenrects may just be parts of the text itself if it's split between multiple lines.
textthe text to search
flagsthe flags to consider during matching
rotatethe rotation to apply for the search order
Warning
Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float.
Since
0.31

◆ search() [4/4]

QList< QRectF > Poppler::Page::search ( const QString &  text,
SearchMode  caseSensitive,
Rotation  rotate = Rotate0 
) const

Returns a list of all occurrences of the specified text on the page.

Parameters
textthe text to search
caseSensitivewhether to be case sensitive
rotatethe rotation to apply for the search order
Warning
Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float.
Since
0.22

◆ text() [1/2]

QString Poppler::Page::text ( const QRectF &  rect) const

Returns the text that is inside a specified rectangle.

The text is returned using the physical layout of the page

Parameters
rectthe rectangle specifying the area of interest, with coordinates given in points, i.e., 1/72th of an inch. If rect is null, all text on the page is given

◆ text() [2/2]

QString Poppler::Page::text ( const QRectF &  rect,
TextLayout  textLayout 
) const

Returns the text that is inside a specified rectangle.

Parameters
rectthe rectangle specifying the area of interest, with coordinates given in points, i.e., 1/72th of an inch. If rect is null, all text on the page is given
Since
0.16

◆ textList() [1/2]

QList< TextBox * > Poppler::Page::textList ( Rotation  rotate,
ShouldAbortQueryFunc  shouldAbortExtractionCallback,
const QVariant &  closure 
) const
   Returns a list of text of the page

   This method returns a QList of TextBoxes that contain all
   the text of the page, with roughly one text word of text
   per TextBox item.

   For text written in western languages (left-to-right and
   up-to-down), the QList contains the text in the proper
   order.

   \param shouldAbortExtractionCallback callback that will be called
   to ask if the text extraction should be cancelled.

   \param closure opaque structure that will be passed
   back to shouldAbortExtractionCallback.

   \note The caller owns the text boxes and they should
         be deleted when no longer required.

   \warning This method is not tested with Asian scripts
Since
0.63

◆ textList() [2/2]

QList< TextBox * > Poppler::Page::textList ( Rotation  rotate = Rotate0) const

Returns a list of text of the page.

This method returns a QList of TextBoxes that contain all the text of the page, with roughly one text word of text per TextBox item.

For text written in western languages (left-to-right and up-to-down), the QList contains the text in the proper order.

Note
The caller owns the text boxes and they should be deleted when no longer required.
Warning
This method is not tested with Asian scripts

◆ thumbnail()

QImage Poppler::Page::thumbnail ( ) const

Get the page thumbnail if it exists.

Returns
a QImage of the thumbnail, or a null image if the PDF does not contain one for this page
Since
0.12

◆ transition()

PageTransition * Poppler::Page::transition ( ) const

Returns the transition of this page.

Returns
a pointer to a PageTransition structure that defines how transition to this page shall be performed.
Note
The PageTransition structure is owned by this page, and will automatically be destroyed when this page class is destroyed.

The documentation for this class was generated from the following file: