PDF Viewer

PRO

View PDF documents inline with page navigation, zoom, and download controls.

Live preview
Interact with the component to see results here.
View code
HTML
<sy-pdf-viewer
  src="/assets/examples/guide.pdf"
  file-name="syidax-guide.pdf"
  height="380px"
  page="1"
  zoom="100"
  show-toolbar
  downloadable
  printable
  fullscreenable
  id="sample"
></sy-pdf-viewer>

Usage guide

#

Let users view PDFs directly within a page using the browser's built-in PDF viewer.

File and viewing area
Set src to an accessible PDF URL, set fileName, and provide enough container height. The example below uses a two-page document.
Pages and zoom
setPage() accepts 1 or higher; setZoom() accepts 25–400.
Document tools
Configure download, print, and fullscreen options for your use case.

Feature examples

#

Choose a feature from 24 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Property · Downloadable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Empty Text

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Fallback Text

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · File Name

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Fullscreenable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Height

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Page

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Printable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Show Toolbar

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Src

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Zoom

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Methods · print

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · reload

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · setFullScreen

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · setPage

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · setRestore

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · setToggle

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · setZoom

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Events · Failed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Fullscreen Changed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Loaded

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Page Changed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Zoom Changed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

API reference

#

Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.

<sy-pdf-viewer>

Properties

Attribute / PropertyTypeDefaultDescription
string''PDF file URL.
string'document.pdf'Download filename and accessible label. Spec name: `file-name`.
number1Current page number, starting at 1.
number100Zoom percentage, limited to 25–400.
string'640px'Height as a CSS length or a numeric string interpreted as pixels.
booleantrueShow the toolbar above the viewer. Spec name: `show-toolbar`.
booleantrueExpose the download action.
booleantrueExpose the print action.
booleantrueExpose the fullscreen toggle.
string'PDF preview is not available in this browser.'Fallback message shown when the browser cannot render the PDF natively. Spec name: `fallback-text`.
string'No PDF selected'Empty-state text when `src` is not provided. Spec name: `empty-text`.

Events

EventDetailDescription
CustomEvent<{ src: string }>Read the result from the event's detail.
CustomEvent<{ src: string }>Read the result from the event's detail.
CustomEvent<{ page: number }>Read the result from the event's detail.
CustomEvent<{ zoom: number }>Read the result from the event's detail.
CustomEvent<{ active: boolean }>Read the result from the event's detail.

Methods

MethodReturnsDescription
Promise<void>Change the PDF page, limited to 1 or higher.
Promise<void>Change the PDF zoom level within 25–400%.
Promise<void>Reload the current PDF.
Promise<void>Open the PDF in a new window for printing.
Promise<void>Request native fullscreen on the viewer host.
Promise<void>Restore the window to its original size.
Promise<void>Toggle between fullscreen and restored.

Slots

SlotDescription
Content displayed in the empty area.