For the complete documentation index, see llms.txt. This page is also available as Markdown.

Pdf Viewer Apis

Functions to open PDF files in a native, in-app viewer instead of downloading them or handing them off to an external app.

The WebToNative PDF Viewer plugin renders the file natively — search, thumbnails, password-protected files, download, and share are all handled in-app.

You'll need to import the javascript file in your website before starting from this link.

Platform support: Android and iOS.


Setting Up PDF Viewer

  1. Go to your WebToNative dashboardAdd-onsPDF Viewer and enable it.

  2. Configure the toolbar/behavior options you want under the same add-on page:

Dashboard field
Maps to
Default
Description

Toolbar Title

toolbarTitle

(uses the title passed from JS)

Overrides the title argument if set to a non-blank value.

Show Download

showDownload

Off

Shows a download-to-device button in the toolbar.

Show Share

showShare

Off

Shows a share-sheet button in the toolbar.

Show Search

showSearch

Off

Shows an in-document search button.

Show Thumbnails

showThumbnails

Off

Shows a page-thumbnail grid button.

Show Page Indicator

showPageIndicator

Off on Android, On on iOS

Shows a page-number pill at the bottom. See the platform-difference hint below.

Auto-Detect PDF Links

autoDetectLinks

Off

If a link the user taps inside your site resolves to a .pdf URL, opens it in the native viewer instead of navigating the WebView. See Auto-Detect Matching below.

URL Patterns

urlPatterns

(empty)

Only used when Auto-Detect is on — see below.

Error Message

errorMessage

(native default message)

Custom text shown if a PDF fails to load.

Error Button Text

errorButtonName

"Retry"

Label for the retry button on the error screen.


JavaScript API Reference

openPDF

Opens a PDF from a URL in the native in-app viewer.

Parameters:

Key
Type
Required
Description

url

String

Yes

The URL of the PDF to open. Throws a JavaScript error immediately (before reaching native code) if blank.

title

String

No

Shown in the viewer's toolbar, unless the dashboard's Toolbar Title field is set to a non-blank value, which takes priority.


Auto-Detect Matching Differs By Platform

If you enable Auto-Detect PDF Links, the matching rule against urlPatterns is not identical on both platforms:

  • Android opens the viewer for any URL simply ending in .pdf. urlPatterns is only consulted as a fallback for URLs that don't end in .pdf (substring match).

  • iOS requires the URL to both end in .pdf and match at least one entry in urlPatterns as a prefix. A bare .pdf URL with Auto-Detect on and no urlPatterns configured will open automatically on Android but not on iOS.

If you need consistent behavior, always fill in urlPatterns explicitly rather than relying on the "any .pdf URL" fallback that only exists on Android.


Frequently Asked Questions

Why does the page-number indicator show on iOS but not Android with the same config?

showPageIndicator defaults to off on Android and on iOS when left unset in the dashboard. Set it explicitly if you need matching behavior across platforms.

Can I pass search/thumbnails/download settings directly in the `openPDF()` call?

No — openPDF only accepts url and title. Everything else is configured once, for the whole app, via the dashboard's PDF Viewer add-on settings.

What happens if a PDF requires a password?

The viewer shows a native password-entry screen and retries opening the file once a password is submitted. There is currently no JavaScript event for "password required" — the user is prompted entirely natively.

Last updated