The Pdf-js Plugin is for Grav CMS. It allows you to embed PDF.js into pages via shortcode.

Please note that this guide is not updated to the latest version 0.2.0 (will be updated asap)

The most important change is the alternatives added to pdf-js. Now you can also use pdfobject or embed or object tags

new grav.pdf

Current View


Installing the Pdf-js plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's terminal (also called the command line). From the root of your Grav install type:

bin/gpm install pdf-js

This will install the Pdf-js plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/pdf-js.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to pdf-js. You can find these files on GitHub or via

You should now have all the plugin files under


NOTE: This plugin is a modular component for Grav which requires Grav and the Error, Problems and Shortcode Core plugins to operate.

Admin Plugin

If you use the admin plugin, you can install directly through the admin plugin by browsing the Plugins tab and clicking on the Add button.


Before configuring this plugin, you should copy the user/plugins/pdf-js/pdf-js.yaml to user/config/plugins/pdf-js.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true
height: 300

Note that if you use the admin plugin, a file with your configuration, and named pdf-js.yaml will be saved in the user/config/plugins/ folder once the configuration is saved in the admin.


This plugin uses the Shortcode Core infrastructure. Read those docs for the nitty gritty of how shortcodes work.

The Pdf-js shortcode is a self-closing

PDFJs: Could not resolve file name '[pdfjs option1=value1 option2=value2 ...'.

, and it accepts the following options:

  • file is the only required parameter. It points to the datafile you wish to load. By default, the plugin looks in the same folder as the page file. This is adequate for most usage. You can also load files from the user/data folder by prefixing your file name with data: (e.g., file=data:folder/filename.pdf).

    If all you're passing is the file name, then you can shorten the code to the form .

Example Codes

  • or (basic embed of pdf file in the same folder as the page itself)

  • or (basic embed of pdf file in the user/data folder)


Pdf-js is a general-purpose, web standards-based platform for parsing and rendering PDFs of Mozilla. More informations are available here:

To Do

  • [ ] Reduce the size of the library.

  • [ ] Make the toolbar buttons available via Admin.

  • [ ] Solve this warning if possible: Warning: Setting up fake worker.

Previous Post