Skip to content

aidevelopers2/iwork-preview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-preview

Use

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 document

From 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

About

Read Apple iWork files (.pages/.numbers/.key) without Apple's apps — extracts the embedded QuickLook preview PDF. One function, works in Node and the browser.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors