Skip to content

Instantly share code, notes, and snippets.

@yiping-allison

yiping-allison/embedpdf.md Secret

Last active Feb 13, 2020
Embed
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>
	</object>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment