Skip to content

Instantly share code, notes, and snippets.

Last active February 13, 2020 06:09
What would you like to do?
HUGO Shortcode to display PDFs using a browser's native viewer

Embed PDF Shortcode

Designed For: George Cushen's Academic Theme

If the browser is able to render the PDF file, it will do so. If not, the browser will display an error message and link to the address given in the url parameter of the shortcode.

Usage: {{< embedpdf url="pdfURL" >}}

<div class="responsive-wrap">
	<object data="{{ .Get "url" }}" type="application/pdf" style="margin: 0 auto;height: 100vh;width: 100%;">
		<embed src="{{ .Get "url" }}" type="application/pdf "style="margin: 0 auto;height: 100vh;width: 100%;">
			<em>It seems that your browser cannot display the PDF file; Please use this <a href="{{ .Get "url" }}"><strong>link</strong> </a>
			instead. Thanks!</em>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment