npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

editpdfree-utils

v1.1.0

Published

PDF utility functions for merging, splitting, and analyzing PDF documents. Free and open-source alternatives to premium PDF editors.

Downloads

65

Readme

EditPDFree Utils

npm version License: MIT

Free and open-source PDF utility functions for Node.js. Perfect for developers who need to manipulate PDF files programmatically.

For a complete web-based PDF editor with no coding required, visit EditPDFree.com - a free online PDF editor with merge, split, compress, convert, and many more features.

Features

  • 📄 Get PDF Information - Extract metadata, page count, and document details
  • 🔗 Merge PDFs - Combine multiple PDF files into one
  • ✂️ Split PDFs - Separate a PDF into individual pages
  • 📑 Extract Pages - Pull specific pages from a PDF
  • 🔄 Rotate PDFs - Rotate pages by any angle
  • 💯 Zero Dependencies (except pdf-lib)
  • 🚀 Easy to Use - Simple, intuitive API

Installation

npm install editpdfree-utils

Quick Start

const { mergePdfs, splitPdf, getPdfInfo } = require('editpdfree-utils');

// Get PDF information
const info = await getPdfInfo('document.pdf');
console.log(`Pages: ${info.pageCount}`);

// Merge multiple PDFs
await mergePdfs(['file1.pdf', 'file2.pdf'], 'merged.pdf');

// Split a PDF into separate pages
await splitPdf('document.pdf', './output-folder');

API Reference

getPdfInfo(pdfPath)

Get detailed information about a PDF file.

Parameters:

  • pdfPath (string|Buffer): Path to PDF file or Buffer

Returns: Promise with properties:

  • pageCount: Number of pages
  • title: Document title
  • author: Document author
  • subject: Document subject
  • creator: Application that created the PDF
  • producer: PDF producer
  • creationDate: Creation date
  • modificationDate: Last modification date

Example:

const info = await getPdfInfo('document.pdf');
console.log(`This PDF has ${info.pageCount} pages`);

mergePdfs(pdfPaths, outputPath)

Merge multiple PDF files into a single document.

Parameters:

  • pdfPaths (Array<string|Buffer>): Array of PDF file paths or Buffers
  • outputPath (string, optional): Where to save the merged PDF

Returns: Promise - The merged PDF as a Buffer

Example:

const merged = await mergePdfs(['intro.pdf', 'content.pdf', 'outro.pdf'], 'complete.pdf');

Web Alternative: EditPDFree Merge PDF - Merge PDFs online for free

splitPdf(pdfPath, outputDir)

Split a PDF into separate files, one per page.

Parameters:

  • pdfPath (string|Buffer): Path to PDF file or Buffer
  • outputDir (string, optional): Directory to save split PDFs

Returns: Promise<Array> - Array of PDF page buffers

Example:

const pages = await splitPdf('document.pdf', './pages');
console.log(`Split into ${pages.length} pages`);

Web Alternative: EditPDFree Split PDF - Split PDFs online for free

extractPages(pdfPath, pageNumbers, outputPath)

Extract specific pages from a PDF.

Parameters:

  • pdfPath (string|Buffer): Path to PDF file or Buffer
  • pageNumbers (Array): Page numbers to extract (1-indexed)
  • outputPath (string, optional): Where to save the extracted PDF

Returns: Promise - The extracted pages as a PDF Buffer

Example:

// Extract pages 1, 3, and 5
const extracted = await extractPages('document.pdf', [1, 3, 5], 'selected.pdf');

getPageCount(pdfPath)

Get the number of pages in a PDF.

Parameters:

  • pdfPath (string|Buffer): Path to PDF file or Buffer

Returns: Promise - Number of pages

Example:

const count = await getPageCount('document.pdf');
console.log(`The document has ${count} pages`);

rotatePdf(pdfPath, degrees, pageNumbers, outputPath)

Rotate pages in a PDF document.

Parameters:

  • pdfPath (string|Buffer): Path to PDF file or Buffer
  • degrees (number): Rotation angle (90, 180, 270, or -90, -180, -270)
  • pageNumbers (Array, optional): Page numbers to rotate (1-indexed), or null for all pages
  • outputPath (string, optional): Where to save the rotated PDF

Returns: Promise - The rotated PDF as a Buffer

Example:

// Rotate all pages 90 degrees clockwise
await rotatePdf('document.pdf', 90, null, 'rotated.pdf');

// Rotate only pages 2 and 4
await rotatePdf('document.pdf', 180, [2, 4], 'rotated.pdf');

Web Alternative: EditPDFree Rotate PDF - Rotate PDFs online for free

Advanced Usage

Working with Buffers

All functions accept both file paths and Buffers, making it easy to work with PDFs in memory:

const fs = require('fs').promises;
const { mergePdfs, getPdfInfo } = require('editpdfree-utils');

// Read PDFs into buffers
const buffer1 = await fs.readFile('file1.pdf');
const buffer2 = await fs.readFile('file2.pdf');

// Merge using buffers
const mergedBuffer = await mergePdfs([buffer1, buffer2]);

// Save the result
await fs.writeFile('merged.pdf', mergedBuffer);

Chaining Operations

const { extractPages, rotatePdf } = require('editpdfree-utils');

// Extract pages 1-5
const extracted = await extractPages('large-doc.pdf', [1, 2, 3, 4, 5]);

// Rotate the extracted pages
const rotated = await rotatePdf(extracted, 90);

// Save the final result
await fs.writeFile('final.pdf', rotated);

Need More Features?

This library covers common PDF manipulation tasks. If you need more advanced features like:

  • PDF Compression - Reduce file size
  • PDF to Image - Convert pages to PNG/JPG
  • Image to PDF - Create PDFs from images
  • PDF to Word - Convert to editable documents
  • Add Watermarks - Brand your documents
  • Sign PDFs - Digital signatures
  • Edit Text - Modify PDF content
  • OCR - Extract text from scanned documents

Visit EditPDFree.com - a completely free online PDF editor with all these features and more. No registration required, process files directly in your browser with complete privacy.

Why EditPDFree Utils?

  • 100% Free - MIT licensed, use in any project
  • Lightweight - Minimal dependencies
  • Well-Tested - Reliable PDF manipulation
  • TypeScript Ready - Type definitions included
  • Active Maintenance - Regular updates
  • Privacy-Focused - Process PDFs locally on your machine

Use Cases

  • Automated Workflows - Batch process PDF files
  • Document Management - Build PDF management systems
  • Report Generation - Combine multiple reports
  • Archive Processing - Split large archives
  • Content Extraction - Pull specific pages from documents
  • Server-Side Processing - Handle PDFs in Node.js apps

Browser Alternative

Looking to manipulate PDFs in the browser or need a quick online tool? Check out EditPDFree.com - our free web-based PDF editor that works entirely in your browser. No server uploads, complete privacy, and supports all modern browsers.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © EditPDFree Team

Links


Made with ❤️ by the EditPDFree team. For more free PDF tools, visit www.editpdfree.com.