Skip to content

RoneoOrg/hugo-embed-pdf-shortcode-roneo

 
 

Repository files navigation

License visitors

Table of Contents


Introduction

This is a Hugo Shortcode developed for use in Hugo based websites. This shortcode allows you to embed a PDF file in a page on your Hugo website. It is developed using the PDF.js library by Mozilla.

This fork brings the following updates:

  • add a download button
  • display every pages of the PDF instead of a pagination
  • fix URL

The code was produced by SuryaThiru, I'm just wrapping up here.

hugo-embed-pdf-shortcode cover

Setup

Note: This shortcode is for use in Hugo based websites. It will not work anywhere else.

1.Install as a Git submodule

git submodule add  https://github.com/anvithks/hugo-embed-pdf-shortcode.git themes/hugo-embed-pdf-shortcode
  1. Edit config.toml:
theme = ["hugo-embed-pdf-shortcode", "YourCurrentTheme"]
enableInlineShortcodes = true

To learn more about "Theme components", see the Hugo documentation

Usage

[Back to Top]

In your Hugo website place the following shortcode in any of the markdown pages.

{{< embed-pdf url="./path/to/pdf/file/example.pdf" >}}

To hide pagination

{{< embed-pdf url="./path/to/pdf/file/example.pdf" hidePaginator="true" >}}

To render a selected page number

{{< embed-pdf url="./path/to/pdf/file/example.pdf" renderPageNum="5" >}}

To hide loading spinner

{{< embed-pdf url="./path/to/pdf/file/example.pdf" hideLoader="true" >}}

Parameters

  • url (required) : The relative location of the file.
  • hidePaginator (optional): Boolean which expects true or false. Hides the paginator for single page documents.
  • renderPageNum (optional): Integer which expects any number from 1 up to the last page number in the document. Will render that specific page on initial load.
  • hideLoader (optional): Boolean which expects true or false. Hides the loading spinner while your document loads.

Note: Currently supports local file embed. If absolute URL from the remote server is provided, configure the CORS header on that server.

FAQ

[Back to Top]

Troubleshooting

You should carefully check the parameter baseURL from your config.toml file.

Use the Firefox Dev Tools, and especially the Console and Network tabs to verify the paths and get debug informations.

Support

[Back to Top] You an reach me at:

For any bugs, enhancement requests, feature requests please raise issues here

Who uses Hugo Embed Pdf Shortcode

[Back to Top]

Dirk's Changelog

License

[Back to Top]

License

About

A shortcode for Hugo(https://gohugo.io/) which allows you to embed a PDF file in a page using Pdf.js (https://mozilla.github.io/pdf.js/)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 89.4%
  • CSS 7.3%
  • HTML 3.3%