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

@utilitly/pdf-rotate

v0.1.0

Published

Rotate PDF pages by multiples of 90 degrees in Node.js or the browser, losslessly. Nothing is uploaded.

Readme

@utilitly/pdf-rotate

Rotate PDF pages in Node.js or the browser: every page, or just the ones you name, by any multiple of 90 degrees.

Scanners love to save a landscape page sideways. rotatePdf fixes that by updating each page's /Rotate entry, the same lossless approach as the Rotate PDF tool on utilitly.com. Nothing is re-rendered, so text stays selectable and images keep their quality.

Install

npm install @utilitly/pdf-rotate

You get ESM, CommonJS and TypeScript types, with pdf-lib as the single dependency.

Rotate pages in 30 seconds

In Node.js, turning the sideways pages of a scan:

import { readFile, writeFile } from 'node:fs/promises'
import { rotatePdf } from '@utilitly/pdf-rotate'

const fixed = await rotatePdf(await readFile('scan.pdf'), 90, { pages: '2, 5-end' })
await writeFile('scan-fixed.pdf', fixed)

In the browser, flipping a whole document upside down:

import { rotatePdf } from '@utilitly/pdf-rotate'

// file: a File from <input type="file" accept="application/pdf">
const flipped = await rotatePdf(await file.arrayBuffer(), 180)
const url = URL.createObjectURL(new Blob([flipped], { type: 'application/pdf' }))

API

rotatePdf(pdf, angle, options?)

Returns Promise<Uint8Array> with the rotated PDF.

| Parameter | Type | | | --- | --- | --- | | pdf | Uint8Array \| ArrayBuffer | The PDF. A Node.js Buffer is fine. | | angle | number | Clockwise, in degrees: 90, 180, 270. Negative turns counter-clockwise (-90). Any multiple of 90 is accepted. | | options.pages | string | Which pages to turn, e.g. '1, 3-end'. Every page when you leave it out. | | options.onProgress | (done, total) => void \| Promise<void> | Runs after each rotated page and is awaited. total counts only the pages being turned. |

The angle is added to the rotation a page already has, then kept within 0-270. A page stored at 270 and turned by 180 ends up at 90, never at 450, so every PDF reader shows it the same way.

Errors

rotatePdf throws a PdfError whose code is one of:

| code | When | | --- | --- | | INVALID_OPTIONS | angle isn't a whole multiple of 90 (45, 1.5, NaN), or pages isn't a string. | | NO_PAGES | pages doesn't match any page in the document. | | NOT_A_PDF | The bytes can't be read as a PDF. | | ENCRYPTED | The PDF has a password. Take it off, then rotate. | | INVALID_INPUT | pdf isn't a Uint8Array or ArrayBuffer. |

Why nothing is uploaded

Rotation is a small edit to each page's dictionary, made in memory by pdf-lib in your own process. There's no request to make and none is made: the Network panel stays empty from start to finish.

Good to know

  • Only each page's /Rotate value changes. Page content, form fields and bookmarks are untouched; pdf-lib does set the file's producer to pdf-lib and its modification date to now.
  • Rotating by 0 or 360 is allowed and leaves every page as it was, which keeps code that passes user input straight through simple.

License

MIT. Built on pdf-lib, MIT as well.

Sibling packages: merge · split · delete pages · reorder pages · duplicate pages