Viewer Options


Highlighting PDF Viewer supports the following parameters passed via URL query:

  • file - URL to PDF file to open in viewer.
  • highlightsFile - URL to highlighting meta data for highlighting in viewer.
  • downloadFile - An alternative PDF download URL to be used when user clicks on download button.
  • downBtnShow - Set to 0 to hide the Download button.
  • downBtnText - Set to 1 to show the Download button text.
  • hideHlErrors - Set to 1 to hide PDF Highlighter error messages in viewer.
  • hideHlMessages - Set to 1 to hide PDF Highlighter notices in viewer.
  • hit - When the highlight file is provided, the document will open on the first hit. This parameter allows you to specify a different number or use "last" or "first".
  • hitNavLoc - Location of hit navigation buttons: use "1" for the find bar (default), or "2" for the main toolbar (as in Highlighter 4.0 and older).
  • powerSearch - Set to 0 to disable Power Search (see below).
  • printBtnShow - Set to 0 to hide the Print button.
  • printBtnText - Set to 1 to show the Print button text.
  • nativePrint - Set to 1 to use browser default PDF printing method as a workaround for blurry printing in PDF.js. For native print to work, PDF document and viewer script must have the same origin (i.e. the same web host name and port).
  • bookmarkBtnShow - Set to 1 to show bookmark button, otherwise it's hidden by default.
  • presModeShow - Set to 1 to show PDF.js presentation mode button, otherwise it's hidden by default
  • style - Custom CSS to include.
  • script - Custom JavaScript files to load. To load multiple files separate them by comma.
  • favicon - URL to favicon
  • hlSrv - URL to PDF Highlighter. You need this only if you're using PDF viewer from a non-default location (e.g. you copied the viewer from Highlighter to a different location on your web site/app) but still want to use features that require server after document was opened (e.g. power search).
  • hlCopy - Set to 0 to disable text copy workaround.
  • wsc - If set to 1, white-space in copied text will be compressed and new line characters replaced with a single space.
  • roll - Set to 0 to disable jump to the first hit after reaching the last hit.
  • showFirstLast - Set to 1 to show First/Last hit navigation buttons.

Setting Viewer Options#

All above listed appearance options can be defined in the highlighter.viewer config section (without the need to modify document serving path), and Highlighter will add them to the viewer URL automatically. For example:

highlighter {
viewer {
printBtnShow = 1
nativePrint = 0
roll = 0

Hit Navigation Modes#

Highlighting PDF Viewer has two different modes for navigating between found search terms in a document.

The default hit navigation mode is hit-to-hit. Controls for the next/previous hit are used to jump from one matching term to the other โ€” with the current term being marked. The number of hits in the toolbar is the number of found terms.

The alternative hit navigation mode is page-to-page. The number of hits in the toolbar is the number of pages containing at least one search term. In page-to-page hit navigation mode, clicking on next hit will advance you to the next page in the PDF file containing a hit(s) rather than jumping to the next individual hit word.

To enable page-to-page navigation, add to application.conf:

highlighter {
viewer {
hitNavigationStrategy = "page-to-page"

JavaScript Hooks#

JavaScript hooks allow tighter integration of the PDF Viewer with your search solution.

Supported JavaScript hooks:

  • onNoNextHit: function() - This handler will be invoked if user clicks the "Next Hit" button, but there are no more hits in the current PDF document.
  • onNoPrevHit: function() - As above but for the "Previous Hit".
  • getPreferencesValue: function(name) - Intercepts PDF.js preferences value getter.
  • getInitialScale: function(storedScale, options) - Return PDF document scale to use on load. Possible values: page-width, page-height, page-fit, auto.
  • onScaleChange: function(scale) - Listener for scale change event.
  • setViewerTitle: function(title) - Intercepts title update.

To define a hook, in a JavaScript file, create function named by the hook and add path to the js file as value of the script parameter:

highlighter {
viewer {
script = "/scripts/my-script-dependency.js,/scripts/myhooks.js"

Exported JavaScript Functions#

The viewer exposes the following JavaScript functions (added to window) that you could use to control navigation from a custom script:

  • showPrevHit: function()
  • showNextHit: function()
  • showNthHit: function(hit)
  • showPage: function(page)