
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
pdfuse-core
Advanced tools
Merge PDFs in the browser: load files with pdf-lib, combine selected pages, export bytes. TypeScript, ESM & CJS.
pdfuse-core is a small, headless JavaScript / TypeScript library for merging PDF files in the browser. It builds on pdf-lib and gives you typed helpers to load uploaded PDFs, read page counts, and merge selected pages from multiple documents into one downloadable PDF (as a Uint8Array).
Use it in React, Vue, Svelte, or vanilla apps where users pick files with <input type="file"> and you want client-side PDF merge without a server.
File and get a pdf-lib PDFDocument plus total page countUploadedPDF, PageSelectionKey, etc.)import / require)sideEffects: false)npm install pdfuse-core
pnpm add pdfuse-core
yarn add pdfuse-core
Peer environment: loadPdfDocument uses the browser File and FileReader APIs. Use it in environments that provide those (typical browser or compatible runtimes). The merge helper only needs the in-memory PDFDocument instances you already loaded.
import { loadPdfDocument } from "pdfuse-core";
async function onFileSelected(file: File) {
const { pdfDoc, totalPages } = await loadPdfDocument(file);
console.log(totalPages, pdfDoc);
}
Each uploaded PDF is represented as an UploadedPDF: metadata plus the loaded pdf-lib document. PageSelectionKey picks a zero-based page from a PDF by its index in your array.
import { loadPdfDocument, mergeSelectedPages } from "pdfuse-core";
import type { UploadedPDF, PageSelectionKey } from "pdfuse-core";
const files: File[] = /* from input or drop zone */;
const pdfs: UploadedPDF[] = await Promise.all(
files.map(async (file, i) => {
const { pdfDoc, totalPages } = await loadPdfDocument(file);
return {
id: `doc-${i}`,
file,
pdfDoc,
totalPages,
};
}),
);
// Order matters: first page of first PDF, then page 3 of second PDF, etc.
const selectedOrder: PageSelectionKey[] = [
{ pdfIndex: 0, pageIndex: 0 },
{ pdfIndex: 1, pageIndex: 2 },
];
const pdfBytes: Uint8Array = await mergeSelectedPages(pdfs, selectedOrder);
// Example: trigger download in the browser
const blob = new Blob([pdfBytes], { type: "application/pdf" });
const url = URL.createObjectURL(blob);
const a = Object.assign(document.createElement("a"), { href: url, download: "merged.pdf" });
a.click();
URL.revokeObjectURL(url);
| Export | Description |
|---|---|
isPdfFile(file) | Returns true if the File looks like a PDF (MIME type or .pdf extension). |
loadPdfDocument(file) | Loads a PDF from a File; returns { pdfDoc, totalPages }. Throws if not a PDF, unreadable, or has no pages. Uses ignoreEncryption: true when loading. |
mergeSelectedPages(pdfs, selectedOrder) | Creates a new PDF containing the chosen pages in order; returns Uint8Array. Skips invalid indices safely. |
| Type | Purpose |
|---|---|
UploadedPDF | id, file, pdfDoc (pdf-lib), totalPages |
PageSelectionKey | pdfIndex (into the pdfs array), pageIndex (0-based page) |
LoadedPDF | id, pdfDoc, totalPages (no File) |
PageSelection | Alternative shape: one LoadedPDF plus pages: number[] |
Types re-export PDFDocument usage via pdf-lib; advanced edits can use the returned pdfDoc with pdf-lib directly.
loadPdfDocument expects File + FileReader (browser-style APIs)packages/core)MIT
FAQs
Merge PDFs in the browser: load files with pdf-lib, combine selected pages, export bytes. TypeScript, ESM & CJS.
We found that pdfuse-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.