You can use the UMD Module as mentioned in their GitHub page. Here are some of the useful information I extracted from their GitHub page.
UMD Module
You can also download pdf-lib as a UMD module from unpkg or jsDelivr. The UMD builds have been compiled to ES5, so they should work in any modern browser. UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the tag of an HTML page.
The following builds are available:
- https://unpkg.com/pdf-lib/dist/pdf-lib.js
- https://unpkg.com/pdf-lib/dist/pdf-lib.min.js
- https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.js
- https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.min.js
NOTE: if you are using the CDN scripts in production, you should include a specific version number in the URL, for example:
- https://unpkg.com/[email protected]/dist/pdf-lib.min.js
- https://cdn.jsdelivr.net/npm/[email protected]/dist/pdf-lib.min.js
Example:
<html>
<head>
<meta charset="utf-8" />
<script src="https://unpkg.com/pdf-lib"></script>
</head>
<body>
<div style="display: flex; width: 100%; height: 100%; flex-direction: column; overflow: hidden;">
<iframe id="pdf" style="flex-grow: 1; border: none; margin: 0; padding: 0;"></iframe>
</div>
</body>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/pdf-lib.min.js"></script>
<script>
createPdf();
async function createPdf() {
const pdfDoc = await PDFLib.PDFDocument.create();
const page = pdfDoc.addPage([350, 400]);
page.moveTo(110, 200);
page.drawText('Hello World!');
const pdfDataUri = await pdfDoc.saveAsBase64({ dataUri: true
});
document.getElementById('pdf').src = pdfDataUri;
}
</script>
</html>
Answer from Lakshitha Kanchana on Stack OverflowPDF-LIB
pdf-lib.js.org
PDF-LIB · Create and modify PDF documents in any JavaScript environment.
import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib'; async function modifyPdf() { const url = 'https://pdf-lib.js.org/assets/with_update_sections.pdf' const existingPdfBytes = await fetch(url).then(res => res.arrayBuffer()) const pdfDoc = await PDFDocument.load(existingPdfBytes) const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica) const pages = pdfDoc.getPages() const firstPage = pages[0] const { width, height } = firstPage.getSize() firstPage.drawText('This text was added with JavaScript!', { x: 5, y: height / 2 + 300, size: 50, font: helveticaFont, color: rgb(0.95, 0.1, 0.1), rotate: degrees(-45), }) const pdfBytes = await pdfDoc.save() }
npm
npmjs.com › package › pdf-lib
pdf-lib - npm
pdf-lib can create, fill, and read PDF form fields. The following field types are supported: ... See the form creation and form filling usage examples for code samples. Tests 1, 14, 15, 16, and 17 in the complete examples contain working example ...
» npm install pdf-lib
Published Nov 06, 2021
Version 1.17.1
Author Andrew Dillon
Repository https://github.com/Hopding/pdf-lib
Homepage https://pdf-lib.js.org/
Videos
07:35
Build a PDF-LIB PDF Editor to Highlight,Redact and Annotate ...
03:28
✨ Generate PDFs Dynamically in Node.js with PDF-Lib 📄 Full ...
19:23
Javascript PDF-LIB Tutorial to Add Page Numbers to All Pages of ...
04:19
Build a PDF.js PDF Canvas Editor Using PDF-LIB & Fabric.js ...
Javascript PDF-LIB Tutorial to Create PDF Document Using ...
12:09
Javascript PDF-LIB Tutorial to Merge Multiple PDF Documents in ...
GitHub
github.com › Hopding › pdf-lib
GitHub - Hopding/pdf-lib: Create and modify PDF documents in any JavaScript environment
pdf-lib can create, fill, and read PDF form fields. The following field types are supported: ... See the form creation and form filling usage examples for code samples. Tests 1, 14, 15, 16, and 17 in the complete examples contain working example ...
Starred by 8.1K users
Forked by 828 users
Languages TypeScript 80.9% | HTML 9.9% | JavaScript 8.5% | Objective-C 0.3% | CSS 0.2% | Starlark 0.1% | Java 0.1%
PDF-LIB
pdf-lib.js.org › docs › api
pdf-lib · PDF-LIB
pdf-lib · BlendMode · ColorTypes · Duplex · ImageAlignment · LineCapStyle · LineJoinStyle · NonFullScreenPageMode · ParseSpeeds · PrintScaling · ReadingDirection · RotationTypes · StandardFonts · TextAlignment · TextRenderingMode · PDFButton · PDFCheckBox ·
Mozilla
mozilla.github.io › pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.
GitHub
github.com › rivy › js.pdf-lib
GitHub - rivy/js.pdf-lib: Create and modify PDF documents in any JavaScript environment
Some of the code for stream decoding was ported directly to TypeScript for use in pdf-lib. jspdf is a PDF generation library for the browser.
Author rivy
PDF-LIB
pdf-lib.js.org › docs › api › classes › pdfdocument
PDFDocument - PDF-LIB - JS.ORG
const pdfDoc = await PDFDocument.create() const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf' const sourceBuffer = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer()) const sourcePdfDoc = await PDFDocument.load(sourceBuffer) const sourcePdfPage = sourcePdfDoc.getPages()[73] const embeddedPage = await pdfDoc.embedPage( sourcePdfPage, // Clip a section of the source page so that we only embed part of it { left: 100, right: 450, bottom: 330, top: 570 }, // Translate all drawings of the embedded page by (10, 200) units [1, 0, 0, 1, 10, 200], )
Apache PDFBox
products.documentprocessing.com › metadata › javascript › pdf-lib
pdf-lib for JavaScript | Manage PDF Metadata Easily
June 25, 2025 - Pdf-lib is a free and open source JavaScript library for working with PDF documents to perform operations such as creating new PDFs from scratch, modifying existing ones or reading and updating metadata of PDF documents.
cdnjs
cdnjs.com › home › libraries › pdf-lib
pdf-lib - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
https://pdf-lib.js.org/ Tags: pdf-lib, pdf, document, create, modify, creation, modification, edit, editing, typescript, javascript, library · Version · 1.17.1 · Loading... Asset Type · All · Loading... https://cdnjs.cloudflare.com/ajax/libs/pdf-lib/1.17.1/pdf-lib.min.js ·
PDF-LIB
pdf-lib.js.org › docs › api › classes › pdfpage
PDFPage - PDF-LIB - JS.ORG
import { degrees } from 'pdf-lib' const pdfDoc = await PDFDocument.create() const page = pdfDoc.addPage() const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf' const sourcePdf = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer()) // Embed page 74 from the PDF const [embeddedPage] = await pdfDoc.embedPdf(sourcePdf, 73) page.drawPage(embeddedPage, { x: 250, y: 200, xScale: 0.5, yScale: 0.5, rotate: degrees(30), opacity: 0.75, }) The options argument accepts both width/height and xScale/yScale as options.
JSFiddle
jsfiddle.net › Hopding › 64zajhge › 1
Modify Document (pdf-lib) - JSFiddle - Code Playground
The Code Completion will now also have the context of all panels before suggesting code to you - so if for example you have some CSS or JS, the HTML panel will suggest code based on the other two panels.
GitHub
github.com › mozilla › pdf.js
GitHub - mozilla/pdf.js: PDF Reader in JavaScript
To use PDF.js in a web application you can choose to use a pre-built version of the library or to build it from source. We supply pre-built versions for usage with NPM under the pdfjs-dist name.
Starred by 52.4K users
Forked by 10.5K users
Languages JavaScript 71.3% | Fluent 25.5% | CSS 2.2%
npm
npmjs.com › package › pdfjs-lib
pdfjs-lib - npm
This is a pre-built version of the PDF.js source code. It is automatically generated by the build scripts. For usage with older browsers or environments, without support for modern features such as optional chaining, nullish coalescing, and private class fields/methods; please see the legacy/ folder. See https://github.com/mozilla/pdf.js for learning and contributing.
» npm install pdfjs-lib
Published Jan 12, 2023
Version 0.0.149
Repository https://github.com/mozilla/pdfjs-dist
Homepage http://mozilla.github.io/pdf.js/
GitHub
github.com › Hopding › pdf-lib › blob › master › docs › CONTRIBUTING.md
pdf-lib/docs/CONTRIBUTING.md at master · Hopding/pdf-lib
compiled/dist/pdf-lib.min.js - a single JavaScript file containing a minified UMD version of the project.
Author Hopding
GitHub
github.com › pdfme › pdf-lib
GitHub - pdfme/pdf-lib: Create and modify PDF documents in any JavaScript environment
pdf-lib can create, fill, and read PDF form fields. The following field types are supported: ... See the form creation and form filling usage examples for code samples. Tests 1, 14, 15, 16, and 17 in the complete examples contain working example ...
Starred by 16 users
Forked by 7 users
Languages TypeScript 71.1% | HTML 21.5% | JavaScript 6.8% | Objective-C 0.2% | CSS 0.2% | Starlark 0.1% | Java 0.1%