{"id":17152282,"url":"https://github.com/anvithks/hugo-embed-pdf-shortcode","last_synced_at":"2025-08-20T12:32:21.965Z","repository":{"id":38382974,"uuid":"292317924","full_name":"anvithks/hugo-embed-pdf-shortcode","owner":"anvithks","description":"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/)","archived":false,"fork":false,"pushed_at":"2023-11-22T09:18:47.000Z","size":6532,"stargazers_count":136,"open_issues_count":12,"forks_count":56,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-10T00:42:07.766Z","etag":null,"topics":["embed-pdf","hugo","pdf-viewer","pdfjs","pdfjs-inside","shortcode"],"latest_commit_sha":null,"homepage":"https://hugo-embed-pdf.netlify.app/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anvithks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-02T15:13:08.000Z","updated_at":"2024-12-02T01:52:38.000Z","dependencies_parsed_at":"2024-11-15T09:04:58.527Z","dependency_job_id":"643b0768-6705-424b-899c-9af120c99100","html_url":"https://github.com/anvithks/hugo-embed-pdf-shortcode","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvithks%2Fhugo-embed-pdf-shortcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvithks%2Fhugo-embed-pdf-shortcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvithks%2Fhugo-embed-pdf-shortcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvithks%2Fhugo-embed-pdf-shortcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anvithks","download_url":"https://codeload.github.com/anvithks/hugo-embed-pdf-shortcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230423564,"owners_count":18223435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embed-pdf","hugo","pdf-viewer","pdfjs","pdfjs-inside","shortcode"],"created_at":"2024-10-14T21:43:18.733Z","updated_at":"2024-12-19T11:13:13.682Z","avatar_url":"https://github.com/anvithks.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![License](https://img.shields.io/:license-mit-blue.svg?style=flat-square)](https://badges.mit-license.org) ![visitors](https://visitor-badge.glitch.me/badge?page_id=anvithks.hugo-embed-pdf-shortcode)\n# hugo-embed-pdf-shortcode  \n\n---  \n# Table of Contents  \n\n* [Online Demo](https://hugo-embed-pdf.netlify.app/)\n* [Introduction](#introduction)\n* [Setup](#setup)  \n* [Usage](#usage)  \n* [FAQ](#faq)  \n* [Support](#support)  \n* [Who uses embed-pdf](#who-uses-hugo-embed-pdf-shortcode)\n* [License](#license)  \n\n---\n\n## Introduction\n[\\[Back to Top\\]](#table-of-contents)\n\nThis is a [Hugo Shortcode](https://gohugo.io/extras/shortcodes/) developed for use in [Hugo](https://gohugo.io/) 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](https://mozilla.github.io/pdf.js/) library by Mozilla.\n\n![hugo-embed-pdf-shortcode cover](hugo-embed-pdf-cover.png)\n\n## Setup\n[\\[Back to Top\\]](#table-of-contents)\n\n**Note:**  This shortcode is for use in Hugo based websites. It will not work anywhere else.\n\nHugo embed-pdf can be installed in two ways.\n\n### Method 1 - Install as a Git submodule\n\n1. Add this shortcode as a Git submodule\n\n```shell\ngit submodule add  https://github.com/anvithks/hugo-embed-pdf-shortcode.git themes/hugo-embed-pdf-shortcode\n```\n\n2. Edit `config.toml` as follows\n\n```\ntheme = [\"hugo-embed-pdf-shortcode\", \"YourCurrentTheme\"]\nenableInlineShortcodes = true\n```\n\n**To learn more about \"Theme components\", see [the Hugo documentation](https://gohugo.io/hugo-modules/theme-components/)**\n\n\u003chr /\u003e\n\n### Method 2 - Clone this repository\n\n1. Clone this repository\n\u003cbr /\u003e\n\n```shell\ngit clone https://github.com/anvithks/hugo-embed-pdf-shortcode.git\ncd hugo-embed-pdf-shortcode\n```\n\n2. Copy the file `./layouts/shortcodes/embed-pdf.html` to  `./layouts/shortcodes` in your Hugo website directory.  \n\u003cbr /\u003e\n\n**Note:** If you do not have a `./layouts/shortcodes` directory you can create it.  \n\n```shell\ncp ./layouts/shortcodes/embed-pdf.html /path/to/your/hugo/website/layouts/shortcodes\n```  \n\u003cbr /\u003e\n\n3. Copy the pdf.js library files from `./static/js/pdf-js` to `./static/js` in your Hugo website directory.  \n\u003cbr /\u003e\n\n**Note:** If you do not have a `./static/js` directory you can create it.  \n\n```shell\ncp -R ./static/js/pdf-js /path/to/your/hugo/website/static/js/\n```  \n\u003chr /\u003e\n\n## Usage  \n[\\[Back to Top\\]](#table-of-contents)\n\nIn your Hugo website place the following shortcode in any of the markdown pages. \n```\n{{\u003c embed-pdf url=\"./path/to/pdf/file/example.pdf\" \u003e}}\n\n```\n\nTo hide pagination\n```\n{{\u003c embed-pdf url=\"./path/to/pdf/file/example.pdf\" hidePaginator=\"true\" \u003e}}\n```\n\n\nTo render a selected page number\n```\n{{\u003c embed-pdf url=\"./path/to/pdf/file/example.pdf\" renderPageNum=\"5\" \u003e}}\n```\n\nTo hide loading spinner\n```\n{{\u003c embed-pdf url=\"./path/to/pdf/file/example.pdf\" hideLoader=\"true\" \u003e}}\n```\n\n### Parameters\n- **url (required)** : The relative location of the file.  \n\n- **hidePaginator (optional)**: Boolean which expects `true` or `false`. Hides the paginator for single page documents. \n\n- **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.\n\n- **hideLoader (optional)**: Boolean which expects `true` or `false`. Hides the loading spinner while your document loads. \n\n\u003cbr /\u003e\n\n**Note:** Currently supports local file embed. If absolute URL from the remote server is provided, configure the CORS header on that server.\n\n\n## FAQ  \n[\\[Back to Top\\]](#table-of-contents)\n\n1. I have installed hugo-embed-pdf in my website locally by cloning the repository and copying the files, but it does not work?  \nA. hugo-embed-pdf uses pdf.js from mozilla. Pdf.js is now being served using a CDN.  \nIf you would like to use a local copy of PDf.js then you can make the following changes to the `embed-pdf.html` file.\n- Change the script tag at the top of the file from\n```js\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/pdfjs-dist@3.4.120/build/pdf.min.js\" integrity=\"sha256-UZQVSEoMbJ82/3uFjt4mYOTVVHIImtkp7u3L6LMH6/Y=\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n```\n\n**to**  \n\n```js\n\u003cscript type=\"text/javascript\" src='{{\"/js/pdf-js/build/pdf.js\" | relURL}}'\u003e\u003c/script\u003e\n```\n- Change the path to the `pdf.worker.js` file at line number 124 from  \n\n```js\npdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@3.4.120/build/pdf.worker.min.js';\n```\n\n**to**  \n\n```js\npdfjsLib.GlobalWorkerOptions.workerSrc = \"{{.Site.BaseURL}}\" + 'js/pdf-js/build/pdf.worker.js';\n```\n\n## Support  \n[\\[Back to Top\\]](#table-of-contents)\nYou an reach me at:\n- Twitter : [@anvith3](https://twitter.com/anvith3)\n\nFor any bugs, enhancement requests, feature requests please raise issues [here](https://github.com/anvithks/hugo-embed-pdf-shortcode/issues)\n\n## Who uses Hugo Embed Pdf Shortcode\n[\\[Back to Top\\]](#table-of-contents)\n\n[Dirk's Changelog](https://changelog.deimeke.ruhr/2019/08/11/workshop-20190811/)  \n[SYSADMIN - Administration, security and hardening of Linux](https://sysadmin.info.pl/pl/blog/moja-praca-inzynierska/)  \n\n## License  \n[\\[Back to Top\\]](#table-of-contents)\n\n[![License](https://img.shields.io/:license-mit-blue.svg?style=flat-square)](https://badges.mit-license.org)\n\n- **[MIT license](https://opensource.org/licenses/mit-license.php)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanvithks%2Fhugo-embed-pdf-shortcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanvithks%2Fhugo-embed-pdf-shortcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanvithks%2Fhugo-embed-pdf-shortcode/lists"}