Gottox / node-pdfutils

tool for analyzing and converting PDF
103 stars 23 forks source link

Flattr this git repo

PDF Utils for node

This library contains tools for analysing and converting PDF files. You can get metadata, extract text, render pages to svg or png, all with our beloved asynchronous programming style.

It is planed to support extracting links from the document and create ImageMaps (You remember them, don't you?) on the fly. Also pdfutils should support password locked files. But that's still on the todo.

The library is currently beta. This means it has incomplete error handling and it lacks a testing suite.

Installation

To install pdfutils you have to install libpoppler-glib first.

Using Debian execute:

apt-get install libpoppler-glib-dev libpoppler-glib8 libcairo2-dev libcairo2

Using CentOS execute:

yum install poppler poppler-glib-devel

Using MacOS and Macports:

port install poppler

or if you prefere brew:

brew install poppler --with-glib
export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig

Then install pdfutils

npm install pdfutils

Usage

See this very basic example:

var pdfutils = require('pdfutils').pdfutils;

pdfutils("document.pdf", function(err, doc) {
    doc[0].asPNG({maxWidth: 100, maxHeight: 100}).toFile("firstpage.png");
});

3sloc to generate thumbnails of PDFs. Awesome!

Here a bit more documentation:

pdfutils(source, callback)

this function is a factory for Documents

arguments:

Class PDFDocument

This class is generated by pdfutils(source, callback) described above.

members:

Class PDFPage

This class represents a page of a document

members:

Class PDFPageJob

This class inherits Stream. It handles converting a Page (described above) to SVG, PNG or Text

members:

events:

members:

License

This module is licensed under GPL.