pdfSetLinkClickCbk
Set a callback function for clicks on hyperlinks.
void pdfSetLinkClickCbk(PDFViewerHandle viewer,
void (*cbk)(void *data, char *linkType, char *dest, int page),
void *data)
This function sets a callback function which will be called when the
user clicks on a hyperlink.
The callback will be called even if hyperlinks are disabled (see
pdfEnableHyperlinks
). However, if XpdfViewer's internal mouse
handling is disabled (e.g., by use of pdfSetMouseDownCbk
or any of
the other mouse callbacks), the link click callback will not be called
if there is a current selection. In general, your mouse down callback
should clear any custom selection.
This callback can be used to do processing on hyperlinks, for example, to disallow following of certain types of links.
The callback receives four arguments:
data
: the value passed in thedata
argument topdfSetLinkClickCbk
linkType
: the type of link (see below)dest
: the link destination (depends on the link type - see below)page
: the link destination page number (depends on the link type - see below)
linkType = "goto"
: a link to another page in the same PDF file -dest
is an empty string, andpage
is the destination page numberlinkType = "pdf"
: a link to another PDF file -dest
is the target PDF file name, andpage
is 0linkType = "launch"
: an arbitrary command to be run -dest
is the command, andpage
is 0linkType = "url"
: a URL link -dest
is the URL, andpage
is 0linkType = "named"
: a "named action" link -dest
is the named action (see the PDF spec for details), andpage
is 0linkType = "unknown"
: an unknown link type -dest
is an empty string, andpage
is 0
C:
void linkClickCbk(void *data, char *linkType, char *dest, int page) {
Context *myContext = (Context *)data;
if (!strcmp(linkType, "goto")) {
....
} else ....
}
....
pdfSetLinkClickCbk(viewer, &linkClickCbk, &myContext);