This plugin embeds inline PDFs in a GitBook.
The plugin will copy all .pdf
files in ./assets/
to the output directory (at the time of writing, Gitbook doesn't do this natively).
This plugin exposes a {% pdf }
block to embed a pdf into a webpage.
- Configure the plugin in your
book.json
:
{
"plugins": ["embed-pdf"]
}
- Embed a PDF using the
pdf
block:
{% pdf src="/assets/example.pdf", width="100%", height="850" %}{% endpdf %}
This would produce the following HTML
<div class="pdf">
<div class="pdf__link">
<a target="_blank" href="/assets/example.pdf">View PDF</a>
</div>
<object data="/assets/example.pdf" width="100%" height="850" type="application/pdf">
<embed src="/assets/example.pdf">
<p>
This browser does not support PDFs. <br>
Please download the PDF to view it: <a target="_blank" href="/assets/example.pdf">Download PDF</a>.
</p>
</object>
</div>
The pdf
block takes the following attributes
src
: (required) the url to the PDF to embedwidth
: the width of the object containing the PDFheight
: the height of the object containing the PDFlink
: (default=true) shows a link to view the PDF in a new browser window/tab