PDF.js viewer URLs: file, page and zoom

WT PDF.js - Documentation

The query is ?file=...&config=catalog.json ; the fragment is #page=2&zoom=150 .

PDF location and initial view parameters

The query is ?file=...&config=catalog.json; the fragment is #page=2&zoom=150. Encode the complete file value through rawurlencode(), http_build_query() or URLSearchParams, particularly for spaces, non-ASCII names and PDF URLs containing their own ? and &. Escape the final URL in HTML.

ParameterExamplePurpose
file/images/documents/catalog.pdfQuery: PDF sharing the viewer origin.
configcatalog.jsonQuery: user JSON filename.
page2Fragment: page number, starting at 1.
zoom150, page-width, page-fit, autoFragment: zoom percentage or mode.
pagemodethumbs, bookmarks, attachments, layers, noneFragment: sidebar mode.

The complete viewer requires matching PDF and viewer origins: scheme, hostname and port. It rejects remote file URLs even when CORS permits access. Host the PDF on your site or use your own server endpoint with access checks. Direct getDocument() use can load remote PDFs with suitable CORS. JSON is also fetched from the viewer origin.

WebTolk Joomla Extensions

113 Extensions
12 Categories
582 Versions released
893721 Downloads