XpdfWidget/Qt
Public Types | Signals | Public Member Functions | Static Public Member Functions | Friends | List of all members
XpdfWidget Class Reference

A PDF viewer widget class for Qt. More...

#include <XpdfWidget.h>

Inheritance diagram for XpdfWidget:

Public Types

enum  ErrorCode {
  pdfOk = 0, pdfErrOpenFile = 1, pdfErrBadCatalog = 2, pdfErrDamaged = 3,
  pdfErrEncrypted = 4, pdfErrHighlightFile = 5, pdfErrBadPrinter = 6, pdfErrPrinting = 7,
  pdfErrPermission = 8, pdfErrBadPageNum = 9, pdfErrFileIO = 10, pdfErrNoHandle = 1001,
  pdfErrOutOfMemory = 1002, pdfErrBusy = 1003, pdfErrBadArg = 1004
}
 Error codes returned by certain XpdfViewer functions. More...
 
enum  DisplayMode {
  pdfDisplaySingle, pdfDisplayContinuous, pdfDisplaySideBySideSingle, pdfDisplaySideBySideContinuous,
  pdfDisplayHorizontalContinuous
}
 Display modes, to be passed to XpdfWidget::setDisplayMode(). More...
 

Signals

void pageChange (int pageNum)
 This signal is emitted whenever the viewer displays a new page. More...
 
void midPageChange (int pageNum)
 This signal is emitted whenever the page shown at the middle of the window changes. More...
 
void preLoad ()
 This signal is emitted just before a PDF file is loaded. More...
 
void postLoad ()
 This signal is emitted just after a PDF file is loaded. More...
 
void keyPress (QKeyEvent *e)
 This signal is emitted whenever a key is pressed. More...
 
void mousePress (QMouseEvent *e)
 This signal is emitted whenever a mouse button is pressed. More...
 
void mouseRelease (QMouseEvent *e)
 This signal is emitted whenever a mouse button is released. More...
 
void mouseMove (QMouseEvent *e)
 This signal is emitted whenever the mouse pointer is moved. More...
 
void mouseWheel (QWheelEvent *e)
 This signal is emitted whenever a mouse wheel is clicked. More...
 
void linkClick (const QString &linkType, const QString &dest, int page)
 This signal is emitted whenever the user clicks on a hyperlink. More...
 
void selectDone ()
 This signal is emitted when the user selects an area. More...
 
void paintDone (bool finished)
 This signal is emitted whenever the widget is repainted. More...
 
void resized ()
 This signal is emitted when the widget is resized. More...
 

Public Member Functions

 XpdfWidget (const QColor &paperColor=QColor(0xff, 0xff, 0xff), const QColor &matteColor=QColor(0x80, 0x80, 0x80), bool reverseVideo=false, QWidget *parentA=0)
 The XpdfWidget constructor. More...
 
 XpdfWidget (QWidget *parentA, const QColor &paperColor=QColor(0xff, 0xff, 0xff), const QColor &matteColor=QColor(0x80, 0x80, 0x80), bool reverseVideo=false)
 The XpdfWidget constructor. More...
 
virtual ~XpdfWidget ()
 Destroys the XpdfWidget. More...
 
void enableHyperlinks (bool on)
 Control handling of hyperlinks. More...
 
void enableSelect (bool on)
 Control handling of text selection. More...
 
void enablePan (bool on)
 Control mouse panning. More...
 
void setKeyPassthrough (bool on)
 Control keypress passthrough. More...
 
void setMousePassthrough (bool on)
 Control mouse event passthrough. More...
 
void showPasswordDialog (bool showDlg)
 Control the password dialog. More...
 
void setMatteColor (const QColor &matteColor)
 Set the matte color, i.e., the color used for background outside the actual page area. More...
 
void setReverseVideo (bool reverse)
 Turn reverse video mode on/off. The default is off. More...
 
void setCursor (const QCursor &cursor)
 Set the cursor. More...
 
void unsetCursor ()
 Reset to the default cursor. More...
 
ErrorCode loadFile (const QString &fileName, const QString &password="")
 Load a PDF file and display its first page. More...
 
ErrorCode loadMem (const char *buffer, unsigned int bufferLength, const QString &password="")
 Load a PDF file from a memory buffer and display its first page. More...
 
ErrorCode readDoc (XpdfDocHandle *docPtr, const QString &fileName, const QString &password="")
 Load a PDF file and return a handle. More...
 
ErrorCode loadDoc (XpdfDocHandle doc)
 Load a PDF document and display its first page. More...
 
void freeDoc (XpdfDocHandle doc)
 Free a PDF document. More...
 
ErrorCode reload ()
 Reload the current PDF file. More...
 
void closeFile ()
 Close the currently open PDF file (if any). More...
 
ErrorCode saveAs (const QString &fileName)
 Save the PDF file with another name. More...
 
QString getFileName () const
 Get the file name of the currently open PDF file. More...
 
bool hasOpenDocument () const
 Returns true if there is currently a PDF file open. More...
 
int getNumPages () const
 Return the number of pages in the currently open PDF file. More...
 
int getCurrentPage () const
 Return the currently displayed page number. More...
 
int getMidPage () const
 Return the page number corresponding to the middle of the window. More...
 
void gotoPage (int pageNum)
 Display the specified page. More...
 
void gotoFirstPage ()
 Display the first page. More...
 
void gotoLastPage ()
 Display the last page. More...
 
void gotoNextPage (bool scrollToTop=true)
 Display the next page. More...
 
void gotoPreviousPage (bool scrollToTop=true)
 Display the previous page. More...
 
bool gotoNamedDestination (const QString &dest)
 Go to a named destination. More...
 
void goForward ()
 Go forward along the history list. More...
 
void goBackward ()
 Go backward along the history list. More...
 
void scrollPageUp ()
 Scroll one screen up. More...
 
void scrollPageDown ()
 Scroll one screen down. More...
 
void scrollTo (int xx, int yy)
 Scroll the page so that the top-left corner of the window is (xx,yy) pixels from the top-left corner of the PDF page. More...
 
void scrollBy (int dx, int dy)
 Scroll the page by (dx,dy) pixels. More...
 
int getScrollX () const
 Return the current scroll position x coordinate. More...
 
int getScrollY () const
 Return the current scroll position y coordinate. More...
 
void setZoom (double zoom)
 Change the zoom factor. More...
 
double getZoom () const
 Return the current zoom factor. More...
 
double getZoomPercent (int page=1) const
 Return the current zoom factor as a percentage. More...
 
void zoomToRect (int page, double xMin, double yMin, double xMax, double yMax)
 Zoom in to the specified rectangle. More...
 
void zoomCentered (double zoom)
 Set the zoom factor, while maintaining the current center. More...
 
void zoomToCurrentWidth ()
 Zoom so that the current page(s) fill the window width. More...
 
void setRotate (int rotate)
 Change the page rotation. More...
 
int getRotate () const
 Return the current page rotation. More...
 
void setContinuousMode (bool continuous)
 Set continuous or single-page view mode. More...
 
bool getContinuousMode () const
 Return true if the viewer is in continuous view mode, or false if it is in any other mode. More...
 
void setDisplayMode (DisplayMode mode)
 Set the display mode. More...
 
DisplayMode getDisplayMode ()
 Return the current display mode. More...
 
bool mouseOverLink ()
 Returns true if the mouse is currently over a hyperlink. More...
 
bool onLink (int page, double xx, double yy)
 Returns true if the specified coordinates are inside a hyperlink. More...
 
QString getLinkInfo (int page, double xx, double yy)
 Get destination information for the hyperlink at the specified page and coordinates. More...
 
QString getMouseLinkInfo ()
 Get destination information for the hyperlink under the mouse. More...
 
bool gotoLinkAt (int page, double xx, double yy)
 Activate the link (if any) at the specified page and coordinates. More...
 
XpdfAnnotHandle onAnnot (int page, double xx, double yy)
 Check for an annotation containing the specified point. More...
 
QString getAnnotType (XpdfAnnotHandle annot)
 Get the annotation type. More...
 
QString getAnnotContent (XpdfAnnotHandle annot)
 Get the annotation's content. More...
 
XpdfFormFieldHandle onFormField (int page, double xx, double yy)
 Check for a form field containing the specified point. More...
 
QString getFormFieldType (XpdfFormFieldHandle field)
 Get the form field's type. More...
 
QString getFormFieldName (XpdfFormFieldHandle field)
 Get the form field's name. More...
 
QString getFormFieldValue (XpdfFormFieldHandle field)
 Get the form field's content. More...
 
void getFormFieldBBox (XpdfFormFieldHandle field, int *pageNum, double *xMin, double *yMin, double *xMax, double *yMax)
 Get the form field's bounding box. More...
 
bool convertWindowToPDFCoords (int winX, int winY, int *page, double *pdfX, double *pdfY)
 Convert window coordinates to PDF coordinates. More...
 
void convertPDFToWindowCoords (int page, double pdfX, double pdfY, int *winX, int *winY)
 Convert PDF coordinates to window coordinates. More...
 
void enableRedraw (bool enable)
 Enable or disable window redraws. More...
 
void getPageBox (int page, const QString &box, double *xMin, double *yMin, double *xMax, double *yMax) const
 Return the coordinates of the specified page box. More...
 
double getPageWidth (int page) const
 Return the width of the specified page. More...
 
double getPageHeight (int page) const
 Return the height of the specified page. More...
 
int getPageRotation (int page) const
 Get the default rotation for the specified page. More...
 
bool hasSelection ()
 Check to see if there is a selection. More...
 
bool getCurrentSelection (int *page, double *x0, double *y0, double *x1, double *y1) const
 Returns the current selection. More...
 
void setCurrentSelection (int page, double x0, double y0, double x1, double y1)
 Set the selection. More...
 
void clearSelection ()
 Clear the selection. More...
 
bool isBlockSelectMode ()
 Check for block selection mode. More...
 
bool isLinearSelectMode ()
 Check for linear selection mode. More...
 
void setBlockSelectMode ()
 Set block selection mode. More...
 
void setLinearSelectMode ()
 Set linear selection mode. More...
 
void setSelectionColor (const QColor &selectionColor)
 Set the selection color. More...
 
void forceRedraw ()
 Force a complete redraw. More...
 
QImage convertPageToImage (int page, double dpi)
 Convert a page to a color image. More...
 
QImage convertRegionToImage (int page, double x0, double y0, double x1, double y1, double dpi)
 Convert a rectangular region of a page to a color image. More...
 
QImage getThumbnail (int page)
 Retrieve an embedded thumbnail image. More...
 
bool okToExtractText () const
 Checks to see if text extraction is allowed. More...
 
void setTextEncoding (const QString &encodingName)
 Set the encoding to use for text extraction. More...
 
QString extractText (int page, double x0, double y0, double x1, double y1)
 Extract text from a region of a page. More...
 
QString getSelectedText ()
 Get the currently selected text. More...
 
void copySelection ()
 Copy the current selection to the clipboard. More...
 
bool find (const QString &text, int flags=0)
 Find a text string. More...
 
int getOutlineNumChildren (XpdfOutlineHandle outline)
 Return the number of children of an outline tree node. More...
 
XpdfOutlineHandle getOutlineChild (XpdfOutlineHandle outline, int idx)
 Return a child of an outline tree node. More...
 
XpdfOutlineHandle getOutlineParent (XpdfOutlineHandle outline)
 Return the parent of an outline tree node. More...
 
QString getOutlineTitle (XpdfOutlineHandle outline)
 Get the title of an outline tree node. More...
 
bool getOutlineStartsOpen (XpdfOutlineHandle outline)
 Return true if the specified outline entry starts open. More...
 
int getOutlineTargetPage (XpdfOutlineHandle outline)
 Return the target page number for the specified outline entry. More...
 
void gotoOutlineTarget (XpdfOutlineHandle outline)
 Jump to the target of the specified outline entry. More...
 
int getNumLayers () const
 Return the number of layers in the PDF file. More...
 
XpdfLayerHandle getLayer (int idx) const
 Get a layer handle. More...
 
QString getLayerName (XpdfLayerHandle layer) const
 Get the name of a layer. More...
 
bool getLayerVisibility (XpdfLayerHandle layer) const
 Get the visibility state of a layer. More...
 
void setLayerVisibility (XpdfLayerHandle layer, bool visibility)
 Set the visibility state of a layer. More...
 
int getLayerViewState (XpdfLayerHandle layer) const
 Get the suggested state for this layer in viewing mode. More...
 
int getLayerPrintState (XpdfLayerHandle layer) const
 Get the suggested state for this layer in printing mode. More...
 
XpdfLayerOrderHandle getLayerOrderRoot () const
 Get the root of the layer display order tree. More...
 
bool getLayerOrderIsName (XpdfLayerOrderHandle order) const
 Check the type of a layer display order tree node. More...
 
QString getLayerOrderName (XpdfLayerOrderHandle order) const
 Get the name of a layer display order tree node. More...
 
XpdfLayerHandle getLayerOrderLayer (XpdfLayerOrderHandle order)
 Get the layer associated with a layer display order tree node. More...
 
int getLayerOrderNumChildren (XpdfLayerOrderHandle order)
 Returns the number of children attached to a layer display order tree node. More...
 
XpdfLayerOrderHandle getLayerOrderChild (XpdfLayerOrderHandle order, int idx)
 Returns the idx 'th child of a layer display order tree node. More...
 
XpdfLayerOrderHandle getLayerOrderParent (XpdfLayerOrderHandle order)
 Return the parent of a layer display order tree node. More...
 
int getNumEmbeddedFiles ()
 Return the number of embedded files in the current PDF file. More...
 
QString getEmbeddedFileName (int idx)
 Return the name of the idx 'th embedded file. More...
 
bool saveEmbeddedFile (int idx, QString fileName)
 Save the idx 'th embedded file with the specified file name. More...
 

Static Public Member Functions

static void init (const QString &configFileName=QString())
 Initialize the XpdfWidget class, reading a configuration file. More...
 
static void setConfig (const QString &command)
 Process a configuration command, i.e., one line of an xpdfrc file. More...
 

Static Public Attributes

Zoom values
static const int zoomToPage = -1
 zoom to fit whole page More...
 
static const int zoomToWidth = -2
 zoom to fit page width More...
 
static const int zoomToHeight = -3
 zoom to fit page height More...
 
Find flags

Flags to be passed to XpdfWidget::find()

static const int findBackward = 0x00000001
 search backward from the starting point More...
 
static const int findCaseSensitive = 0x00000002
 perform a case-sensitive search (default is case-insensitive) More...
 
static const int findNext = 0x00000004
 start searching from the previous search result More...
 
static const int findOnePageOnly = 0x00000008
 limit the search to the current page More...
 
static const int findWholeWord = 0x00000010
 limit the search to whole words More...
 

Friends

class XpdfViewer
 

Detailed Description

A PDF viewer widget class for Qt.

Member Enumeration Documentation

Display modes, to be passed to XpdfWidget::setDisplayMode().

Enumerator
pdfDisplaySingle 

single page

pdfDisplayContinuous 

pages stacked vertically

pdfDisplaySideBySideSingle 

two facing pages

pdfDisplaySideBySideContinuous 

facing pages, stacked vertically

pdfDisplayHorizontalContinuous 

pages stacked horizontally

Error codes returned by certain XpdfViewer functions.

Enumerator
pdfOk 

no error

pdfErrOpenFile 

couldn't open the PDF file

pdfErrBadCatalog 

couldn't read the page catalog

pdfErrDamaged 

PDF file was damaged and couldn't be repaired.

pdfErrEncrypted 

file was encrypted and password was incorrect or not supplied

pdfErrHighlightFile 

nonexistent or invalid highlight file

pdfErrBadPrinter 

invalid printer

pdfErrPrinting 

error during printing

pdfErrPermission 

PDF file doesn't allow that operation.

pdfErrBadPageNum 

invalid page number

pdfErrFileIO 

file I/O error

pdfErrNoHandle 

NULL object handle.

pdfErrOutOfMemory 

out of memory

pdfErrBusy 

PDF component is busy.

pdfErrBadArg 

invalid argument

Constructor & Destructor Documentation

XpdfWidget::XpdfWidget ( const QColor &  paperColor = QColor(0xff, 0xff, 0xff),
const QColor &  matteColor = QColor(0x80, 0x80, 0x80),
bool  reverseVideo = false,
QWidget *  parentA = 0 
)

The XpdfWidget constructor.

Parameters
paperColorthe paper background color (which should generally be left as white)
matteColorthe matte color displayed between pages, and around pages that are smaller than the window
reverseVideosets reverse video at startup
parentAthe parent QWidget
XpdfWidget::XpdfWidget ( QWidget *  parentA,
const QColor &  paperColor = QColor(0xff, 0xff, 0xff),
const QColor &  matteColor = QColor(0x80, 0x80, 0x80),
bool  reverseVideo = false 
)

The XpdfWidget constructor.

Parameters
paperColorthe paper background color (which should generally be left as white)
matteColorthe matte color displayed between pages, and around pages that are smaller than the window
reverseVideosets reverse video at startup
parentAthe parent QWidget This version has the parent argument first so it works correctly with Qt Designer.
virtual XpdfWidget::~XpdfWidget ( )
virtual

Destroys the XpdfWidget.

Member Function Documentation

void XpdfWidget::clearSelection ( )

Clear the selection.

void XpdfWidget::closeFile ( )

Close the currently open PDF file (if any).

Calling this function is optional - the current PDF file will be automatically closed if XpdfWidget::loadFile or XpdfWidget::loadMem is called.

QImage XpdfWidget::convertPageToImage ( int  page,
double  dpi 
)

Convert a page to a color image.

This function converts the page number page to a 24-bit RGB bitmap, at a resolution of dpi dots per inch.

void XpdfWidget::convertPDFToWindowCoords ( int  page,
double  pdfX,
double  pdfY,
int *  winX,
int *  winY 
)

Convert PDF coordinates to window coordinates.

QImage XpdfWidget::convertRegionToImage ( int  page,
double  x0,
double  y0,
double  x1,
double  y1,
double  dpi 
)

Convert a rectangular region of a page to a color image.

This function converts a rectangular region, defined by corners (x0,y0) and (x1,y1), of page number page to a 24-bit RGB bitmap, at a resolution of dpi dots per inch.

bool XpdfWidget::convertWindowToPDFCoords ( int  winX,
int  winY,
int *  page,
double *  pdfX,
double *  pdfY 
)

Convert window coordinates to PDF coordinates.

Returns true if successful, i.e., if the specified point falls on a PDF page.

void XpdfWidget::copySelection ( )

Copy the current selection to the clipboard.

void XpdfWidget::enableHyperlinks ( bool  on)

Control handling of hyperlinks.

If enabled, the viewer will follow hyperlinks when clicked with the left mouse button. If disabled, the viewer will ignore left mouse button clicks on hyperlinks. The default is enabled.

void XpdfWidget::enablePan ( bool  on)

Control mouse panning.

If enabled, dragging with the middle mouse button pressed will pan the page. If disabled, the middle button is ignored. The default is enabled.

void XpdfWidget::enableRedraw ( bool  enable)

Enable or disable window redraws.

This is useful, e.g., for avoiding extra redraws during window resizing. Deprecated – this just calls setUpdatesEnabled().

void XpdfWidget::enableSelect ( bool  on)

Control handling of text selection.

If enabled, the viewer will allow the user to select rectangular regions of text when the user drags with the left mouse button. If disabled, dragging with the left mouse button is ignored. The default is enabled.

QString XpdfWidget::extractText ( int  page,
double  x0,
double  y0,
double  x1,
double  y1 
)

Extract text from a region of a page.

This function extracts and returns text from the rectangular region, defined by corners (x0,y0) and (x1,y1), of page number page. The coordinates returned by XpdfWidget::getCurrentSelection may be passed directly to this function. Returns an empty string if no file is open or if text extraction is not allowed.

bool XpdfWidget::find ( const QString &  text,
int  flags = 0 
)

Find a text string.

This function searches for a Unicode text string. Starts searching after (before, if searching backward) the current selection (if there is a selection), or at the top (bottom, if searching backward) of the current page (if there is no selection). The flags argument consists of zero or more of the following, or-ed together:

  • findBackward - search backward from the starting point
  • findCaseSensitive - perform a case-sensitive search (default is case-insensitive)
  • findNext - start searching from the previous search result
  • findOnePageOnly - limit the search to the current page
  • findWholeWord - limit the search to whole words
void XpdfWidget::forceRedraw ( )

Force a complete redraw.

void XpdfWidget::freeDoc ( XpdfDocHandle  doc)

Free a PDF document.

This function frees a PDF document handle created by XpdfWidget::readDoc. It should only be called if the document is not going to be displayed. That is: after calling XpdfWidget::readDoc, you should call either XpdfWidget::loadDoc or XpdfWidget::freeDoc. The document handle should not be used for anything else after calling this function.

QString XpdfWidget::getAnnotContent ( XpdfAnnotHandle  annot)

Get the annotation's content.

Usage of this depends on the annotation type.

QString XpdfWidget::getAnnotType ( XpdfAnnotHandle  annot)

Get the annotation type.

bool XpdfWidget::getContinuousMode ( ) const

Return true if the viewer is in continuous view mode, or false if it is in any other mode.

Deprecated: see getDisplayMode().

int XpdfWidget::getCurrentPage ( ) const

Return the currently displayed page number.

Returns -1 if no file is open.

bool XpdfWidget::getCurrentSelection ( int *  page,
double *  x0,
double *  y0,
double *  x1,
double *  y1 
) const

Returns the current selection.

If there is a currently active selection, sets *page, (*x0,*y0), and (*x1,*y1) to the page number and upper-left and lower-right coordinates, respectively, and returns true. If there is no selection, returns false.

DisplayMode XpdfWidget::getDisplayMode ( )

Return the current display mode.

QString XpdfWidget::getEmbeddedFileName ( int  idx)

Return the name of the idx 'th embedded file.

QString XpdfWidget::getFileName ( ) const

Get the file name of the currently open PDF file.

void XpdfWidget::getFormFieldBBox ( XpdfFormFieldHandle  field,
int *  pageNum,
double *  xMin,
double *  yMin,
double *  xMax,
double *  yMax 
)

Get the form field's bounding box.

QString XpdfWidget::getFormFieldName ( XpdfFormFieldHandle  field)

Get the form field's name.

QString XpdfWidget::getFormFieldType ( XpdfFormFieldHandle  field)

Get the form field's type.

QString XpdfWidget::getFormFieldValue ( XpdfFormFieldHandle  field)

Get the form field's content.

Usage of this depends on the field type.

XpdfLayerHandle XpdfWidget::getLayer ( int  idx) const

Get a layer handle.

This function returns a handle for the idx 'th layer.

QString XpdfWidget::getLayerName ( XpdfLayerHandle  layer) const

Get the name of a layer.

This function returns the title of layer.

XpdfLayerOrderHandle XpdfWidget::getLayerOrderChild ( XpdfLayerOrderHandle  order,
int  idx 
)

Returns the idx 'th child of a layer display order tree node.

bool XpdfWidget::getLayerOrderIsName ( XpdfLayerOrderHandle  order) const

Check the type of a layer display order tree node.

Returns true if the specified node of the layer display order tree is a name; false if the node is a layer.

XpdfLayerHandle XpdfWidget::getLayerOrderLayer ( XpdfLayerOrderHandle  order)

Get the layer associated with a layer display order tree node.

QString XpdfWidget::getLayerOrderName ( XpdfLayerOrderHandle  order) const

Get the name of a layer display order tree node.

This should only be called if getLayerOrderIsName returns true.

int XpdfWidget::getLayerOrderNumChildren ( XpdfLayerOrderHandle  order)

Returns the number of children attached to a layer display order tree node.

XpdfLayerOrderHandle XpdfWidget::getLayerOrderParent ( XpdfLayerOrderHandle  order)

Return the parent of a layer display order tree node.

This function returns the parent of node order, or NULL if order is the root node.

XpdfLayerOrderHandle XpdfWidget::getLayerOrderRoot ( ) const

Get the root of the layer display order tree.

int XpdfWidget::getLayerPrintState ( XpdfLayerHandle  layer) const

Get the suggested state for this layer in printing mode.

This function returns one of:

  • 1: on
  • 0: off
  • -1: unset
int XpdfWidget::getLayerViewState ( XpdfLayerHandle  layer) const

Get the suggested state for this layer in viewing mode.

This function returns one of:

  • 1: on
  • 0: off
  • -1: unset
bool XpdfWidget::getLayerVisibility ( XpdfLayerHandle  layer) const

Get the visibility state of a layer.

Returns true if the layer is currently visible, false if not.

QString XpdfWidget::getLinkInfo ( int  page,
double  xx,
double  yy 
)

Get destination information for the hyperlink at the specified page and coordinates.

If there is a link at the specified point, returns a string suitable for displaying to a user; otherwise returns an empty string. Note: This function expects PDF coordinates, not window coordinates.

int XpdfWidget::getMidPage ( ) const

Return the page number corresponding to the middle of the window.

QString XpdfWidget::getMouseLinkInfo ( )

Get destination information for the hyperlink under the mouse.

If the mouse is currently over a hyperlink, return an info string (same as with getLinkInfo()); otherwise return an empty string.

int XpdfWidget::getNumEmbeddedFiles ( )

Return the number of embedded files in the current PDF file.

int XpdfWidget::getNumLayers ( ) const

Return the number of layers in the PDF file.

Note that a PDF file can have zero or more layers.

int XpdfWidget::getNumPages ( ) const

Return the number of pages in the currently open PDF file.

Returns -1 if no file is open.

XpdfOutlineHandle XpdfWidget::getOutlineChild ( XpdfOutlineHandle  outline,
int  idx 
)

Return a child of an outline tree node.

This function returns the idx 'th child of node outline, or the idx 'th root entry if outline is NULL.

int XpdfWidget::getOutlineNumChildren ( XpdfOutlineHandle  outline)

Return the number of children of an outline tree node.

This function returns the number of children of node outline, or the number of root outline entries if outline is NULL.

XpdfOutlineHandle XpdfWidget::getOutlineParent ( XpdfOutlineHandle  outline)

Return the parent of an outline tree node.

This function returns the parent of node outline, or NULL if outline is a root item.

bool XpdfWidget::getOutlineStartsOpen ( XpdfOutlineHandle  outline)

Return true if the specified outline entry starts open.

int XpdfWidget::getOutlineTargetPage ( XpdfOutlineHandle  outline)

Return the target page number for the specified outline entry.

QString XpdfWidget::getOutlineTitle ( XpdfOutlineHandle  outline)

Get the title of an outline tree node.

This function returns the title of node outline.

void XpdfWidget::getPageBox ( int  page,
const QString &  box,
double *  xMin,
double *  yMin,
double *  xMax,
double *  yMax 
) const

Return the coordinates of the specified page box.

Parameters
pagethe page number
boxthe requested page box - one of "media", "crop", "bleed", "trim", or "art" (box is not case-sensitive)
*xMinreturns the minimum x coordinate of the box
*yMinreturns the minimum y coordinate of the box
*xMaxreturns the maximum x coordinate of the box
*yMaxreturns the maximum y coordinate of the box

All coordinates are in points (1 point = 1/72 inch).

double XpdfWidget::getPageHeight ( int  page) const

Return the height of the specified page.

This function returns the crop box height, measured in points (1 point = 1/72 inch).

int XpdfWidget::getPageRotation ( int  page) const

Get the default rotation for the specified page.

This is the default viewing rotation specified in the PDF file - it will be one of 0, 90, 180, or 270.

double XpdfWidget::getPageWidth ( int  page) const

Return the width of the specified page.

This function returns the crop box width, measured in points (1 point = 1/72 inch).

int XpdfWidget::getRotate ( ) const

Return the current page rotation.

The angle can be 0, 90, 180, or 270.

int XpdfWidget::getScrollX ( ) const

Return the current scroll position x coordinate.

int XpdfWidget::getScrollY ( ) const

Return the current scroll position y coordinate.

QString XpdfWidget::getSelectedText ( )

Get the currently selected text.

Returns an empty string if there is no selection (or if there is no text in the selected region).

QImage XpdfWidget::getThumbnail ( int  page)

Retrieve an embedded thumbnail image.

This function returns the embedded thumbnail image for the specified page, or a null image if there is no embedded thumbnail. This function does not do any rasterization – it only returns a non-null image if there is an embedded thumbnail in the PDF file.

double XpdfWidget::getZoom ( ) const

Return the current zoom factor.

This can be a percentage factor or one of the special values, XpdfWidget::zoomToPage or XpdfWidget::zoomToWidth.

double XpdfWidget::getZoomPercent ( int  page = 1) const

Return the current zoom factor as a percentage.

If the zoom is set to XpdfWidget::zoomToPage or XpdfWidget::zoomToWidth, returns the computed zoom percentage for the specified page, based on the current window size.

void XpdfWidget::goBackward ( )

Go backward along the history list.

void XpdfWidget::goForward ( )

Go forward along the history list.

void XpdfWidget::gotoFirstPage ( )

Display the first page.

This is equivalent to

void XpdfWidget::gotoLastPage ( )

Display the last page.

This is equivalent to

bool XpdfWidget::gotoLinkAt ( int  page,
double  xx,
double  yy 
)

Activate the link (if any) at the specified page and coordinates.

Returns true if successful. Note: This function expects PDF coordinates, not window coordinates.

bool XpdfWidget::gotoNamedDestination ( const QString &  dest)

Go to a named destination.

void XpdfWidget::gotoNextPage ( bool  scrollToTop = true)

Display the next page.

void XpdfWidget::gotoOutlineTarget ( XpdfOutlineHandle  outline)

Jump to the target of the specified outline entry.

void XpdfWidget::gotoPage ( int  pageNum)

Display the specified page.

void XpdfWidget::gotoPreviousPage ( bool  scrollToTop = true)

Display the previous page.

bool XpdfWidget::hasOpenDocument ( ) const

Returns true if there is currently a PDF file open.

bool XpdfWidget::hasSelection ( )

Check to see if there is a selection.

Returns true if there is a currently active selection.

static void XpdfWidget::init ( const QString &  configFileName = QString())
static

Initialize the XpdfWidget class, reading a configuration file.

If configFileName is non-empty, the specified file is tried first. If configFileName is empty, or the file doesn't exist, the default location is tried (<exe-dir>/xpdfrc on Windows; ~/.xpdfrc on Unix).

This function must be called before any other XpdfWidget functions (including the constructor). It will be called automatically (with a NULL configFileName) if it hasn't already been called when the first XpdfWidget function is used.

bool XpdfWidget::isBlockSelectMode ( )

Check for block selection mode.

Returns true if the current selection mode is block.

bool XpdfWidget::isLinearSelectMode ( )

Check for linear selection mode.

Returns true if the current selection mode is linear.

void XpdfWidget::keyPress ( QKeyEvent *  e)
signal

This signal is emitted whenever a key is pressed.

void XpdfWidget::linkClick ( const QString &  linkType,
const QString &  dest,
int  page 
)
signal

This signal is emitted whenever the user clicks on a hyperlink.

Parameters
linkTypethe type of link - one of:
  • "goto": a link to another page in the same PDF file - dest is empty; page is the destination page number
  • "pdf": a link to another PDF file - dest is the target PDF file; page is 0
  • "launch": an arbitrary command to be run - dest is the command; page is 0
  • "url": a URL link - dest is the URL; page is 0
  • "named": a "named action" link - dest is the action (see the PDF spec for details); page is 0
  • "unknown": an unknown link type - dest is empty; page is 0
destdestination string
pagedestination page number
ErrorCode XpdfWidget::loadDoc ( XpdfDocHandle  doc)

Load a PDF document and display its first page.

This function displays a PDF document handle created by XpdfWidget::readDoc. The document handle should not be used for anything else after calling this function.

Returns
pdfOk if successful; an error code, otherwise
ErrorCode XpdfWidget::loadFile ( const QString &  fileName,
const QString &  password = "" 
)

Load a PDF file and display its first page.

Parameters
fileNamethe PDF file to load
passworda string to be tried first as the owner password and then as the user password
Returns
pdfOk if successful; an error code, otherwise
ErrorCode XpdfWidget::loadMem ( const char *  buffer,
unsigned int  bufferLength,
const QString &  password = "" 
)

Load a PDF file from a memory buffer and display its first page.

Parameters
bufferthe PDF file in memory
bufferLengthlength of buffer
passworda string to be tried first as the owner password and then as the user password
Returns
pdfOk if successful; an error code otherwise
void XpdfWidget::midPageChange ( int  pageNum)
signal

This signal is emitted whenever the page shown at the middle of the window changes.

It is similar to XpdfWidget::pageChange, except that it reflects the page shown at the middle of the window (instead of the page at the top of the window).

void XpdfWidget::mouseMove ( QMouseEvent *  e)
signal

This signal is emitted whenever the mouse pointer is moved.

bool XpdfWidget::mouseOverLink ( )

Returns true if the mouse is currently over a hyperlink.

void XpdfWidget::mousePress ( QMouseEvent *  e)
signal

This signal is emitted whenever a mouse button is pressed.

void XpdfWidget::mouseRelease ( QMouseEvent *  e)
signal

This signal is emitted whenever a mouse button is released.

void XpdfWidget::mouseWheel ( QWheelEvent *  e)
signal

This signal is emitted whenever a mouse wheel is clicked.

bool XpdfWidget::okToExtractText ( ) const

Checks to see if text extraction is allowed.

This function returns false if the currently displayed PDF file is encrypted and does not allow extraction of text (or if no PDF file is currently open). The owner password can be used to circumvent this: if a valid owner password was supplied to XpdfWidget::loadFile, this function will always return true. If this function returns false, the text extraction functions will not return any text.

XpdfAnnotHandle XpdfWidget::onAnnot ( int  page,
double  xx,
double  yy 
)

Check for an annotation containing the specified point.

Returns NULL if there is no annotation at this point. Note: This function expects PDF coordinates, not window coordinates.

XpdfFormFieldHandle XpdfWidget::onFormField ( int  page,
double  xx,
double  yy 
)

Check for a form field containing the specified point.

Returns NULL if there is no annotation at this point. Note: This function expects PDF coordinates, not window coordinates.

bool XpdfWidget::onLink ( int  page,
double  xx,
double  yy 
)

Returns true if the specified coordinates are inside a hyperlink.

Note: This function expects PDF coordinates, not window coordinates.

void XpdfWidget::pageChange ( int  pageNum)
signal

This signal is emitted whenever the viewer displays a new page.

It can be triggered by user actions (e.g., the PageDown button), or program control (e.g., the gotoNextPage function).

Parameters
pageNum- the new page number
void XpdfWidget::paintDone ( bool  finished)
signal

This signal is emitted whenever the widget is repainted.

finished is true if the painted view is complete, or false if this was an incremental update, i.e., if the view is still being rendered.

void XpdfWidget::postLoad ( )
signal

This signal is emitted just after a PDF file is loaded.

void XpdfWidget::preLoad ( )
signal

This signal is emitted just before a PDF file is loaded.

ErrorCode XpdfWidget::readDoc ( XpdfDocHandle docPtr,
const QString &  fileName,
const QString &  password = "" 
)

Load a PDF file and return a handle.

This function can be safely called from a non-GUI thread. Use XpdfWidget::loadDoc (on the GUI thread) to load the document handle into the viewer. The handle returned in *docPtr should be passed to either XpdfWidget::loadDoc or XpdfWidget::freeDoc.

Calling XpdfWidget::readDoc + XpdfWidget::loadDoc is equivalent to calling XpdfWidget::loadFile. The difference is that readDoc can be called on a background thread to avoid stalling the user interface.

Parameters
docPtrthe PDF document handle will be returned her
fileNamethe PDF file to load
passworda string to be tried first as the owner password and then as the user password
Returns
pdfOk if successful; an error code, otherwise
ErrorCode XpdfWidget::reload ( )

Reload the current PDF file.

This reloads the current PDF file, maintaining the zoom and scroll position (if possible). This only works if the PDF file was loaded from a file (i.e., with XpdfWidget::loadFile, not with XpdfWidget::loadMem).

Returns
pdfOk if successful; an error code otherwise
void XpdfWidget::resized ( )
signal

This signal is emitted when the widget is resized.

ErrorCode XpdfWidget::saveAs ( const QString &  fileName)

Save the PDF file with another name.

Parameters
fileNamethe file to be written
Returns
pdfOk if successful; an error code otherwise
bool XpdfWidget::saveEmbeddedFile ( int  idx,
QString  fileName 
)

Save the idx 'th embedded file with the specified file name.

Returns true if successful.

void XpdfWidget::scrollBy ( int  dx,
int  dy 
)

Scroll the page by (dx,dy) pixels.

If dx is positive, scrolls right; if dx is negative, scrolls left. Similarly, positive and negative values of dy scroll down and up, respectively.

void XpdfWidget::scrollPageDown ( )

Scroll one screen down.

void XpdfWidget::scrollPageUp ( )

Scroll one screen up.

void XpdfWidget::scrollTo ( int  xx,
int  yy 
)

Scroll the page so that the top-left corner of the window is (xx,yy) pixels from the top-left corner of the PDF page.

void XpdfWidget::selectDone ( )
signal

This signal is emitted when the user selects an area.

Use XpdfWidget::getCurrentSelection to retrieve the selection.

void XpdfWidget::setBlockSelectMode ( )

Set block selection mode.

In this mode, the selection is a simple rectangle. Any part of the page can be selected, regardless of the content on the page.

static void XpdfWidget::setConfig ( const QString &  command)
static

Process a configuration command, i.e., one line of an xpdfrc file.

Note that this applies globally to all XpdfWidget instances.

void XpdfWidget::setContinuousMode ( bool  continuous)

Set continuous or single-page view mode.

Deprecated: this is equivalent to calling setDisplayMode() with pdfDisplaySingle or pdfDisplayContinuous.

Parameters
continuoustrue for continous view mode, false for single-page view mode
void XpdfWidget::setCurrentSelection ( int  page,
double  x0,
double  y0,
double  x1,
double  y1 
)

Set the selection.

Sets the current selection to the rectangle with upper-left corner (x0,y0) and lower-right corner (x1,y1) on page.

void XpdfWidget::setCursor ( const QCursor &  cursor)

Set the cursor.

The requested cursor will only be displayed in the viewport (not in the scrollbars).

void XpdfWidget::setDisplayMode ( DisplayMode  mode)

Set the display mode.

void XpdfWidget::setKeyPassthrough ( bool  on)
inline

Control keypress passthrough.

If enabled, XpdfWidget will pass keypress events through to the keyPress signal, with no other processing. If disabled, XpdfWidget will implement some built-in key bindings. The default is disabled.

void XpdfWidget::setLayerVisibility ( XpdfLayerHandle  layer,
bool  visibility 
)

Set the visibility state of a layer.

Parameters
layerthe layer handle
visibilitythe new state - true for visible, false for not visible
void XpdfWidget::setLinearSelectMode ( )

Set linear selection mode.

In this mode, the selection follows text. Non-text regions cannot be selected.

void XpdfWidget::setMatteColor ( const QColor &  matteColor)

Set the matte color, i.e., the color used for background outside the actual page area.

The default is a medium gray.

void XpdfWidget::setMousePassthrough ( bool  on)
inline

Control mouse event passthrough.

If enabled, XpdfWidget will pass mouse events through to the mousePress/mouseRelease signals, with no other processing. If disabled, XpdfWidget will implement some built-in mouse handling (in addition to sending the signals). The default is disabled.

void XpdfWidget::setReverseVideo ( bool  reverse)

Turn reverse video mode on/off. The default is off.

void XpdfWidget::setRotate ( int  rotate)

Change the page rotation.

Parameters
rotaterotation angle in degrees - must be 0, 90, 180, or 270
void XpdfWidget::setSelectionColor ( const QColor &  selectionColor)

Set the selection color.

void XpdfWidget::setTextEncoding ( const QString &  encodingName)

Set the encoding to use for text extraction.

The following encodings are predefined:

  • "Latin1": ISO-8859-1 (this is the default value)
  • "ASCII7": 7-bit ASCII
  • "UTF-8": Unicode in UTF-8 format
  • "UCS-2": Unicode in UCS-2 format

Additional encodings can be defined via the xpdfrc config file.

void XpdfWidget::setZoom ( double  zoom)

Change the zoom factor.

This can be a percentage factor (where 100 means 72 dpi) or one of the special values, XpdfWidget::zoomToPage or XpdfWidget::zoomToWidth.

void XpdfWidget::showPasswordDialog ( bool  showDlg)

Control the password dialog.

If enabled, the viewer will show a password dialog for encrypted files; if disabled, it will simply return pdfErrEncrypted unless the correct password is passed to pdfLoadFileWithPassword. The default is enabled.

void XpdfWidget::unsetCursor ( )

Reset to the default cursor.

void XpdfWidget::zoomCentered ( double  zoom)

Set the zoom factor, while maintaining the current center.

Accepts the same zoom values as XpdfWidget::setZoom.

void XpdfWidget::zoomToCurrentWidth ( )

Zoom so that the current page(s) fill the window width.

Maintains the vertical center.

void XpdfWidget::zoomToRect ( int  page,
double  xMin,
double  yMin,
double  xMax,
double  yMax 
)

Zoom in to the specified rectangle.

The coordinate system is the same one used by XpdfWidget::getCurrentSelection. This function will set the zoom factor and scroll position so that the specified rectangle just fits in the window.

Member Data Documentation

const int XpdfWidget::findBackward = 0x00000001
static

search backward from the starting point

const int XpdfWidget::findCaseSensitive = 0x00000002
static

perform a case-sensitive search (default is case-insensitive)

const int XpdfWidget::findNext = 0x00000004
static

start searching from the previous search result

const int XpdfWidget::findOnePageOnly = 0x00000008
static

limit the search to the current page

const int XpdfWidget::findWholeWord = 0x00000010
static

limit the search to whole words

const int XpdfWidget::zoomToHeight = -3
static

zoom to fit page height

const int XpdfWidget::zoomToPage = -1
static

zoom to fit whole page

const int XpdfWidget::zoomToWidth = -2
static

zoom to fit page width


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