Back

VibeFox JS PDF — Demo

Quick start

Plain HTML

The document of the quick start, made in the browser and shown at once in the viewer with page thumbnails; the line added after the viewer was created appears by itself. Save PDF downloads the file.

Open a PDF file

Choose any PDF file of your computer: it is opened and drawn by the library itself, nothing is uploaded. Until then the viewer shows a file made in the code.

Core concepts

Documents and pages

Flowing text from the top margin and a box placed at exact coordinates of the page (points, from the top-left corner). The line under the viewer shows the page count and the flow cursor.

Events

Every event of the viewer and the document is written into the box. Turn pages, zoom, or press Add text: the document emits change and the viewer draws it again.

State snapshots

Change the page, zoom or rotation, press Save state, change them again, then Restore state: the viewer goes back to the saved view.

Creating documents

Pages and the flow

An A5 book in Times: a justified paragraph that runs over the next pages by itself, then a wide A4 landscape page with the flow continuing at y 200.

Text

Text in a box aligned to the right, a line under it at the measured bottom of the box, and a rotated half-transparent stamp text.

Shapes and paths

A circle, a triangle, a Bézier curve, a rounded dashed box and a half-transparent group cut by a clip path — all vector graphics of the page.

Images and SVG

A PNG with transparency (drawn into a canvas right in the example), placed twice from one registered image, and an SVG with a gradient drawn as vector graphics — zoom in to see that it stays sharp.

Tables

A table of 80 rows: the rows go on over three pages and the colored header row is repeated on each. Scroll the pages or click a thumbnail.

Header, footer and watermark

The title in the header, "Page n of m" in the footer and a DRAFT watermark across every page; they are drawn on all three pages.

Links, bookmarks and metadata

Bookmarks with a nested one in the sidebar (click one to open its page) and a link on page 1 that goes to page 3. The metadata title is used as the name of the document.

Saving

The buttons save the same document in different ways: a download, a file without compression, and the size of the bytes. The viewer shows what is saved.

JSON snapshots and merging

The document is saved as JSON, restored from it, and both are merged into one document of four pages (the thumbnails show them).

Fonts

Standard fonts

The standard PDF fonts every reader has: Helvetica, Times and Courier with bold and italic, Symbol and ZapfDingbats; Latin and Cyrillic text in one line. No font file is loaded.

HTML to PDF

An HTML string with its CSS laid out by the library: a styled heading, a link, a table with borders, a list and the page footer. Then a second part is added on a new page.

VibeFox JS components in a PDF

A chart of VibeFox JS Charts (above the viewer) drawn into the PDF as vector graphics, once full width and twice in a grid of two columns. Zoom in: the bars and texts stay sharp.

Opening and changing PDF files

A PDF file (here made in the code and saved to bytes) is opened, gets an APPROVED text and a COPY watermark, and is saved as an incremental update. The box shows what the reader found in the file.

Page operations

Two pages of a document drawn side by side on one landscape sheet, followed by the pages of the source after it was rotated, reordered and shortened.

Viewer

The viewer with its toolbar: thumbnails, page field, previous / next, zoom, fit width, rotation, search, print and download. It shows the classic style, the second page and a rotated view.

Navigation and zoom

The buttons call the methods of the viewer: pages, zoom, fit, rotation and the single-page layout. The box shows the state after each step.

Sidebar: thumbnails, bookmarks, layers, signatures

The sidebar with the bookmarks of the report as a tree; the buttons switch it to thumbnails or close it. Click a bookmark or a thumbnail to open its page.

A floor plan with three layers (optional content, as made by CAD or DTP programs). Turn the layers off and on in the Layers tab or with the button.

Text selection and search

The word "invoice" is found and highlighted (the current match in a stronger color); Next moves to the next match. Select text with the mouse and copy it, or press Ctrl+F in the viewer.

Page editing

The thumbnail panel with the page tool bar: select thumbnails (Ctrl / Shift + click), drag them to a new place, rotate or delete them, undo. The buttons do the same from code.

Printing

The print button of the toolbar or Print pages 1–2 opens the print dialog of the browser with the pages drawn at 200 dpi; the box shows the progress.

Drawing a page without the viewer

Each page of the report drawn into its own canvas at half size, without the viewer component.

Rendering PDF files

The renderer option and pdf.js

An opened PDF file drawn by the library's own renderer (renderer: 'lite'): vector shapes, text in the standard fonts and a transparent image; pdf.js is not used.

Low-level functions

One page of an opened file painted into a canvas with renderPageLite; the text items it returned are outlined in red at their positions.

Text extraction and search

The text of the report read by the library; the amounts found by a regular expression and the e-mail found by the ready-made pattern are marked with highlight annotations in the viewer.

Annotations

From code

A highlight, a note icon, a red box, an arrow, a text box and an APPROVED stamp added from code; they are saved as real PDF annotations.

Exchange and flattening

The annotations of a document exported as XFDF (the box), imported into a copy and flattened there: on the right page they are part of the page content and can no longer be edited.

In the viewer

The annotation toolbar: pick highlight and select text, draw with ink, drag a box or an arrow, click to place a note, or pick a stamp; select an annotation to move, resize or delete it. The box lists what was added.

Visual signatures

A drawn signature with the date and a typed one in a cursive system font. Sign opens the signature dialog (Draw, Type, Image), then click the page to put the signature down.

Forms

Creating fields

A fillable form made in code: text fields with number and e-mail formats, a check box, radio buttons, a combo box, a list, a signature field and buttons. Fill it in right here.

Filling and reading

The form is filled from code; the box shows the values read back, the result of the check and the data exported as XFDF. Reset amount and Fill again change the fields in the viewer too.

Filling in the viewer

Type into the fields: each change is written into the box. Send never sends anything: it checks the form, marks the required empty field and gives the values to your code.

Redaction

The e-mail address and the phone number are marked for redaction (red boxes, listed in the panel). Press Apply redactions: the text under the marks is removed from the file and black boxes are drawn; then search for the address — it is gone.

Document comparison

Comparison view

Two versions of a contract side by side, scrolled together: deleted words marked on the old one, inserted words on the new one, and the list of changes. Next change and Overlay call the methods.

Digital signatures

Signing

A contract signed in the browser with WebCrypto and a test certificate written into the code; the signed file is opened in the viewer, which checks the signature and shows it in the status line and the Signatures tab.

Validation

The signed contract is checked with the test root as trusted (valid) and with nothing trusted (unknown signer); then text is added to the page after signing, and the viewer shows what the check says about that version in its status line and the Signatures tab.

Encryption and permissions

A document saved with AES-256 encryption that opens without a password but does not allow printing or copying: the viewer opens it, and its print button is disabled. The box shows the permissions read from the file.

PDF/A, PDF/UA and tagged PDF

Structure

A tagged document: a heading, paragraphs, a list, a figure with alternative text and a table; the box shows the structure tree that screen readers use.

Checks and conversion

The built-in checks run on a plain document: the PDF/A-2b and PDF/UA errors with the clauses of the standards, then a conversion to PDF/A with what it fixed and what it could not fix (the standard fonts are not embedded; give a font file of yours for that).

Templates and the designer

Templates

An invoice template with placeholders, expressions and filters, a QR code and an EAN-13 bar code, filled with data; the table sums its rows in the footer. The comment line is a fillable field.

Designer

The template designer with the preview data: drag elements from the palette onto the page, select, move and resize them with snapping, edit their properties in the side panel, undo and redo.

Theming and styling

Themes

Pick a theme from the list: the built-in light, dark and high-contrast, the theme pack of vibefox-js-themes.css, and an own theme "brand" registered with registerTheme.

CSS variables

The viewer with a few --vfjs-pdf-* variables set on its element: a dark toolbar with dark buttons, a gray workspace, wider gaps between the pages without a shadow, and a teal accent.

Ready-made styles

The ready-made looks of the viewer: pick classic, dark, minimal, compact or paper from the list.

Density and size

The density of the container changes the heights and paddings of the toolbar and the sidebar; pick compact, normal or comfortable.

Localization and RTL

Languages

The viewer in Russian, with the language pack vibefox-js-pdf.ru.js loaded after the library; English is built in. Switch it with the list. The texts of the PDF itself do not change.

Adding a language

A partial German dictionary added with addLocale: the zoom and download buttons are German, the keys it does not have fall back to English. Hover the buttons to see the tooltips.

Right-to-left

The viewer laid out right-to-left: the toolbar and the sidebar are mirrored and the previous / next buttons point the reading direction; the pages keep their geometry.

Using with other VibeFox JS libraries

Connecting components with link()

Two viewers connected with link(): turn the pages of the left one and the right one follows.

Bug Report

Thank you for helping us improve. We carefully review every report, but we do not reply to them individually. If your report leads to a change, it will be listed in the product changelog together with the report number. To discuss something in detail, please open a support ticket.

Slide to fit the puzzle