iwork-preview
v1.0.0
Published
Extract the embedded preview PDF from Apple iWork files (.pages, .numbers, .key) — read iWork documents on servers, Windows, or the browser without Apple's apps.
Maintainers
Readme
iwork-preview
Read Apple iWork files (.pages, .numbers, .key) anywhere Apple's apps don't run.
Modern iWork documents are zip archives whose internals are proprietary protobuf (IWA format — undocumented, painful). But nearly every file saved by Pages, Numbers, or Keynote also ships with an embedded QuickLook preview PDF that captures the exact layout of the document.
This package finds that PDF and hands it to you. One function, one dependency (fflate), works in Node and the browser.
Install
npm install iwork-previewUse
import { extractPreviewPdf, kindForFilename } from "iwork-preview";
import { readFileSync, writeFileSync } from "node:fs";
const pdf = extractPreviewPdf(readFileSync("report.pages"));
if (pdf) writeFileSync("report.pdf", pdf); // exact-layout PDF of the documentFrom the PDF you can go anywhere: extract the text layer (e.g. with unpdf) and build a .docx, re-table it into .xlsx, or just serve the PDF itself.
When it returns null
- The file was saved without a preview (in the iWork app: File → Advanced → Include Preview in Document)
- Very old pre-2013 iWork files that aren't zip archives
Who uses this
Powers the converters at pagestoword.com, numberstoexcel.com, and keynotetopowerpoint.com — free in-browser iWork conversion, no Mac needed.
MIT © Zac Frulloni
