Skip to content

@capgo/capacitor-pdf-viewer

Embed native PDF viewing on iOS, Android, and web with paths, URLs, base64, inline mode, password support, and underWebView custom HTML UI

underWebView / toBack

Open with mode: 'underWebView' or toBack: true to place the native PDF behind a transparent Capacitor WebView. nativeUi defaults to false in this mode so you can ship your own HTML chrome.

Custom HTML controls

Draw toolbars, page indicators, and buttons in HTML (Ionic, Tailwind, or plain markup). The native layer keeps PDFKit / Pdfium scroll, pinch zoom, and link hit testing.

Touch routing

Touches on button, a, form controls, [data-capgo-pdf-interactive], .custom-toolbar, and .custom-pdf-ui button stay in the WebView. Other touches go to the PDF.

updateLayout()

Reposition or resize the native PDF in CSS pixels relative to the WebView viewport. Call it after rotation or when your chrome changes size.

Embed native PDF viewing on iOS, Android, and web with paths, URLs, base64, inline mode, password support, and an optional underWebView presentation for custom HTML UI.

Start with open() and the other core methods listed below.

PlatformSupportNotes
iOSYesPDFKit. underWebView / toBack is supported. hide() and show() are accepted only in underWebView or inline mode.
AndroidYesPdfium. underWebView / toBack is supported. hide() and show() work in any open mode.
WebPartialBrowser PDF viewer with blob URLs. underWebView / toBack is not available. Use fullscreen or inline. nativeUi: false with mode: 'fullscreen' is rejected.
  • open - Open a PDF from a file, path, URL, or base64 source, including mode: 'underWebView' or toBack: true.
  • close - Close the active viewer and remove any overlay.
  • goToPage / nextPage / previousPage - Jump or step through 1-based pages.
  • setZoom - Set the zoom scale multiplier (1 is the default fit scale on native).
  • hide / show - Hide or show the PDF layer without unloading the document.
  • updateLayout - Reposition or resize the native PDF in underWebView / toBack mode.
MethodDescription
openOpen a PDF from a file, path, URL, or base64 source.
closeClose the active viewer and remove any overlay.
goToPageJump to a 1-based page number.
nextPageMove to the next page when one exists.
previousPageMove to the previous page when one exists.
setZoomSet the zoom scale multiplier. On web this resolves without changing the browser zoom.
getPageCountRead the total page count. On web this always returns 1.
getCurrentPageRead the current 1-based page. On web this reflects the last programmatic page only.
hideHide the PDF layer without unloading the document.
showShow the PDF layer after hide().
updateLayoutReposition or resize the native PDF when using underWebView / toBack.
getPluginVersionGet the native or web implementation version marker.
addListenerListen for load, pageChange, zoomChange, error, close, and linkTap events.

This reference is synced from src/definitions.ts in capacitor-pdf-viewer.

Keep going from @capgo/capacitor-pdf-viewer

Section titled “Keep going from @capgo/capacitor-pdf-viewer”

If you are using @capgo/capacitor-pdf-viewer in your Capacitor app, connect it with Using @capgo/capacitor-pdf-viewer for the SEO tutorial and related Capgo plugin docs.