Skip to main content
Module

x/embed_pdf/mod.js>EmbedPdf

WebComponent for embedding PDF files in web pages using pdf.js
Latest
class EmbedPdf
extends HTMLElement
import { EmbedPdf } from "https://deno.land/x/embed_pdf@v1.3.0/mod.js";

An HTML element that can embed a pdf file.

First, insert a script tag into your HTML. Next, place the <embed-pdf> tag. Finally, set the file path in the src attribute of the <embed-pdf> tag.

<script src="https://deno.land/x/embed_pdf@v1.3.0/mod.js" type="module"></script>
<embed-pdf src="./path/to/file.pdf"></embed-pdf>

screenshot

By default, this library uses pdf.js in the vendor directory to render PDFs. Alternatively, to use the latest version of pdf.js directly from the official site, set it using JavaScript as follows:

import { EmbedPdf } from "https://deno.land/x/embed_pdf@v1.3.0/mod.js";

// Specify the path to viewer.html. The default URL is https://deno.land/x/embed_pdf@v1.3.0/vendor/pdfjs/web/viewer.html .
EmbedPdf.viewerUrl = "https://mozilla.github.io/pdf.js/web/viewer.html";

Constructors

new
EmbedPdf()

Static Properties

observedAttributes: string[]
viewerUrl