Skip to content
Star

PxDocumentViewer

Renders a PDF document inline using pdfjs-dist. It automatically renders all pages of the document sequentially and includes a built-in "Print PDF" action button.

Basic Usage

Demo

Loading PDF...

Props

Props
PropTypeDefaultDescription
urlrequiredstringThe URL of the PDF document to render.
scalenumber1.5The zoom scale applied to the PDF pages.
heightstring'600px'The CSS height of the viewer container.
renderAllPagesbooleantrueIf true, renders all pages sequentially. If false, renders only the initialPage.
initialPagenumber1The specific page to render when renderAllPages is false.

Features

  • Automatic Worker: Automatically configures the pdfjs-dist web worker.
  • Configurable rendering: Use renderAllPages to render every page sequentially, or set it to false and pair it with initialPage to render a single page. scale controls the zoom level (default 1.5).
  • Print Support: Includes a built-in "Print PDF" button that downloads the file to memory as a Blob and opens the native browser print dialog.

Built with VitePress