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.
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
- Edit
config.toml
:
theme = ["hugo-embed-pdf-shortcode", "YourCurrentTheme"]
enableInlineShortcodes = true
To learn more about "Theme components", see the Hugo documentation
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" >}}
- url (required) : The relative location of the file.
- hidePaginator (optional): Boolean which expects
true
orfalse
. 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
orfalse
. 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.
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.
[Back to Top] You an reach me at:
- Twitter : @anvith3
For any bugs, enhancement requests, feature requests please raise issues here