XpdfWidget/Qt
|
A PDF viewer widget class for Qt. More...
#include <XpdfWidget.h>
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... | |
Static Public Attributes | |
Zoom values | |
Special values for XpdfWidget::setZoom() / XpdfWidget::getZoom() | |
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... | |
class | XpdfViewer |
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... | |
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 | enableExternalHyperlinks (bool on) |
Control handling of external hyperlinks. More... | |
void | enableSelect (bool on) |
Control handling of text selection. More... | |
void | enablePan (bool on) |
Control mouse panning. More... | |
void | enableTouchPan (bool on) |
Control touchscreen panning. More... | |
void | enableTouchZoom (bool on) |
Control touchscreen zooming. 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, bool transparent=false) |
Convert a page to a color image. More... | |
QImage | convertRegionToImage (int page, double x0, double y0, double x1, double y1, double dpi, bool transparent=false) |
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... | |
QVector< XpdfFindResult > | findAll (const QString &text, int firstPage, int lastPage, int flags=0) |
Find all occurrences of a text string. More... | |
bool | hasPageLabels () |
Check if the PDF file has page labels. More... | |
QString | getPageLabelFromPageNum (int pageNum) |
Convert a page number to a page label. More... | |
int | getPageNumFromPageLabel (QString pageLabel) |
Convert a page label to a page number. 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... | |
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 | mouseClick (QMouseEvent *e) |
This signal is emitted whenever a mouse button is clicked. More... | |
void | mouseDoubleClick (QMouseEvent *e) |
This signal is emitted whenever a mouse button is double-clicked. More... | |
void | mouseTripleClick (QMouseEvent *e) |
This signal is emitted whenever a mouse button is triple-clicked. 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... | |
A PDF viewer widget class for Qt.
Display modes, to be passed to XpdfWidget::setDisplayMode().
Error codes returned by certain XpdfViewer functions.
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.
paperColor | the paper background color (which should generally be left as white) |
matteColor | the matte color displayed between pages, and around pages that are smaller than the window |
reverseVideo | sets reverse video at startup |
parentA | the 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.
paperColor | the paper background color (which should generally be left as white) |
matteColor | the matte color displayed between pages, and around pages that are smaller than the window |
reverseVideo | sets reverse video at startup |
parentA | the parent QWidget This version has the parent argument first so it works correctly with Qt Designer. |
|
virtual |
Destroys the XpdfWidget.
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, | ||
bool | transparent = false |
||
) |
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. If transparent is true, the returned image will be 32-bit ARGB instead, and will include an alpha channel.
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, | ||
bool | transparent = false |
||
) |
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. If transparent is true, the returned image will be 32-bit ARGB instead, and will include an alpha channel.
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::enableExternalHyperlinks | ( | bool | on | ) |
Control handling of external hyperlinks.
This setting allows disabling external hyperlinks (links that open another PDF file, or that involve a URL), independent of internal hyperlinks (links to locations within the same PDF file). This setting is ignored if all hyperlinks are disabled (enableHyperlinks(false)). The default is enabled.
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.
void XpdfWidget::enableTouchPan | ( | bool | on | ) |
Control touchscreen panning.
If enabled, QPanGestures are recognized and used to pan the PDF view.
void XpdfWidget::enableTouchZoom | ( | bool | on | ) |
Control touchscreen zooming.
If enabled QPinchGestures are recognized and used to pinch-zoom the PDF view.
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 pointfindCaseSensitive
- perform a case-sensitive search (default is case-insensitive)findNext
- start searching from the previous search resultfindOnePageOnly
- limit the search to the current pagefindWholeWord
- limit the search to whole words QVector< XpdfFindResult > XpdfWidget::findAll | ( | const QString & | text, |
int | firstPage, | ||
int | lastPage, | ||
int | flags = 0 |
||
) |
Find all occurrences of a text string.
This function searches for a Unicode text string, in pages firstPage .. lastPage. The flags argument consists of zero or more of the following, or-ed together:
findCaseSensitive
- perform a case-sensitive search (default is case-insensitive)findWholeWord
- limit the search to whole words Returns a list of search results. 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:
int XpdfWidget::getLayerViewState | ( | XpdfLayerHandle | layer | ) | const |
Get the suggested state for this layer in viewing mode.
This function returns one of:
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.
page | the page number |
box | the requested page box - one of "media", "crop", "bleed", "trim", or "art" (box is not case-sensitive) |
*xMin | returns the minimum x coordinate of the box |
*yMin | returns the minimum y coordinate of the box |
*xMax | returns the maximum x coordinate of the box |
*yMax | returns 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).
QString XpdfWidget::getPageLabelFromPageNum | ( | int | pageNum | ) |
Convert a page number to a page label.
Return the page label for page number pageNum. Returns an empty string if the page number is invalid or if the PDF file doesn't have page labels.
int XpdfWidget::getPageNumFromPageLabel | ( | QString | pageLabel | ) |
Convert a page label to a page number.
Return the page number for pageLabel. Returns -1 if there is no matching page label or if the PDF file doesn't have page labels.
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 | ( | ) |
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::hasPageLabels | ( | ) |
Check if the PDF file has page labels.
Return true if the currently open PDF file has page labels.
bool XpdfWidget::hasSelection | ( | ) |
Check to see if there is a selection.
Returns true if there is a currently active selection.
|
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; ~/
on Unix)..xpdfrc
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.
|
signal |
This signal is emitted whenever a key is pressed.
|
signal |
This signal is emitted whenever the user clicks on a hyperlink.
linkType | the type of link - one of:
|
dest | destination string |
page | destination 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.
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.
fileName | the PDF file to load |
password | a string to be tried first as the owner password and then as the user password |
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.
buffer | the PDF file in memory |
bufferLength | length of buffer |
password | a string to be tried first as the owner password and then as the user password |
pdfOk
if successful; an error code otherwise
|
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).
|
signal |
This signal is emitted whenever a mouse button is clicked.
A click is defined as a button press and release within a short distance of each other (a few pixels). The sequence of signals is: mousePress, possibly a few mouseMoves, mouseRelease, and then mouseClick.
|
signal |
This signal is emitted whenever a mouse button is double-clicked.
Double clicks are two clicks within a few pixels of each other, and within a certain time of each other. The sequence of signals is: mousePress, mouseRelease, mouseClick, mousePress, mouseRelease, mouseDoubleClick. There may also be mouseMoves between the presses and releases.
|
signal |
This signal is emitted whenever the mouse pointer is moved.
bool XpdfWidget::mouseOverLink | ( | ) |
Returns true if the mouse is currently over a hyperlink.
|
signal |
This signal is emitted whenever a mouse button is pressed.
|
signal |
This signal is emitted whenever a mouse button is released.
|
signal |
This signal is emitted whenever a mouse button is triple-clicked.
Triple clicks are three clicks within a few pixels of each other, and within a certain time of each other. The sequence of signals is: mousePress, mouseRelease, mouseClick, mousePress, mouseRelease, mouseDoubleClick, mousePress, mouseRelease, mouseTripleClick. There may also be mouseMoves between the presses and releases.
|
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.
|
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).
pageNum | - the new page number |
|
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.
|
signal |
This signal is emitted just after a PDF file is loaded.
|
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.
docPtr | the PDF document handle will be returned her |
fileName | the PDF file to load |
password | a string to be tried first as the owner password and then as the user password |
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).
pdfOk
if successful; an error code otherwise
|
signal |
This signal is emitted when the widget is resized.
ErrorCode XpdfWidget::saveAs | ( | const QString & | fileName | ) |
Save the PDF file with another name.
fileName | the file to be written |
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.
|
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 |
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.
continuous | true 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.
|
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.
layer | the layer handle |
visibility | the 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.
|
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.
rotate | rotation 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 formatAdditional 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.
|
static |
search backward from the starting point
|
static |
perform a case-sensitive search (default is case-insensitive)
|
static |
start searching from the previous search result
|
static |
limit the search to the current page
|
static |
limit the search to whole words
|
static |
zoom to fit page height
|
static |
zoom to fit whole page
|
static |
zoom to fit page width