@embedpdf/snippet
v2.3.0
Published
<div align="center"> <a href="https://www.embedpdf.com"> <img alt="EmbedPDF logo" src="https://www.embedpdf.com/logo-192.png" height="96"> </a>
Readme
📚 Documentation
The full walkthrough, advanced examples, and API reference live in our docs site:
👉 https://www.embedpdf.com/docs/snippet/introduction
🚀 Introduction
EmbedPDF Snippet is a “batteries‑included” drop‑in that turns any <div> into a professional PDF reader. No build step, no framework lock‑in—just copy, paste, and you’re done.
Why choose the Snippet?
- Complete UI out‑of‑the‑box – toolbar, thumbnails, search, zoom & more
- Zero build tooling – works in plain HTML pages or alongside any JS framework
- 30‑second setup – a single
<script type="module">is all you need - Fully configurable – tweak behavior with a lightweight options object
- Runs everywhere – modern browsers, frameworks, static sites & CMSes
⚡️ Quick Install
Add the CDN module and point it at a container:
<div id="pdf-viewer" style="height: 500px"></div>
<script async type="module">
import EmbedPDF from 'https://cdn.jsdelivr.net/npm/@embedpdf/snippet@2/dist/embedpdf.js';
const viewer = EmbedPDF.init({
type: 'container', // mount strategy
target: document.getElementById('pdf-viewer'),
src: 'https://snippet.embedpdf.com/ebook.pdf', // your PDF URL
});
</script>That’s it—refresh and enjoy a full‑featured viewer.
🛠 Basic Usage Pattern
- Container – create a DOM element where the viewer will render.
- Import – load
embedpdf.jsfrom the CDN withtype="module". - Initialize – call
EmbedPDF.init()with your configuration.
Minimal Example
<!DOCTYPE html>
<html>
<head>
<title>My PDF Viewer</title>
</head>
<body>
<div id="pdf-viewer" style="height: 100vh"></div>
<script async type="module">
import EmbedPDF from 'https://cdn.jsdelivr.net/npm/@embedpdf/snippet@2/dist/embedpdf.js';
const viewer = EmbedPDF.init({
type: 'container',
target: document.getElementById('pdf-viewer'),
src: 'https://snippet.embedpdf.com/ebook.pdf',
});
</script>
</body>
</html>📄 License
EmbedPDF Snippet is MIT licensed. Commercial use is welcome—just keep the copyright headers intact.
