How to Display PDF Files in WordPress

Watermark WordPress Files offers a simple way to preview PDF files embedded within pages or posts. So your visitors can view it directly on your site without leaving it, which will keep them stay on your site longer and might increase the conversion rate.

In this article, we will show you how to display PDF files in your WordPress content with Watermark WordPress Files plugin.

Requirements:

Once activating our plugin, go to edit or create a new page and click on our PDF viewer button. It will bring up a popup where you select which PDF file to embed into the content.

Since we haven’t supported the Gutenberg block, you can use the following shortcode instead.

[pda_pdf_viewer id=2454 title="your-file-title"]

The “id” attribute is required and can be found when you hover on the filename.

Once published, your PDF content will display under our Viewer as shown below.

This PDF Viewer provides some basic features:

  1. Use “Next” and “Previous” buttons (or Up and Down on your keyboard) to navigate across pages or scroll continuously between pages.
  2. Go directly to a specific page by typing page number.
  3. Customize PDF content size under view, including automatic zoom, actual size, fit page, full width plus the default zoom in and out.
  4. Get a specific link to your current page to share. Once clicking on the Bookmark button, copy the bookmark link displaying under the address bar.
  5. Rotate the PDF clockwise and counterclockwise.
  6. Download the PDF file. This button is hidden by default. 
  7. Find specific text or keywords the document content.
As of now, you can only use one single PDF viewer per page/post. If you insert more than one, only the first document will display correctly.

Customize the viewer

You can optionally change the width and height of the viewer by adding some additional parameters to the shortcode as follows:

[pda_pdf_viewer id=2454 width="500" height="725"]

Secure PDF files

The following functions will be disabled by default to make it difficult for viewers to copy, share or download your files.

  • Right-click or select text on the viewer
  • Inspect elements to get PDF file link
  • Download button on the toolbar

However, these minor tricks can’t prevent download tools such as IDM from downloading your files. To protect your files more effectively, you can consider apply watermark to your files as well as storing them on a private S3 bucket.

In the opposite case, if you want to enable downloading, go to the plugin’s settings page and turn the corresponding option on.

To display the download button out of the viewer, simply use the shortcode below.

[pda_pdf_download]

Lasted updated on April 20, 2020