Giter Club home page Giter Club logo

pdfspin's Introduction

pdfspin

PDF manipulation in Node.js. (Forked from spindrift by timcameronryan)

Example

var pdfspin = require('pdfspin');

// Use and chain any of these commands...
var pdf = pdfspin('in.pdf')
   .pages(7, 24)
   .page(1)
   .even()
   .odd()
   .rotate(90)
   .compress()
   .uncompress()
   .crop(100, 100, 300, 200) // left, bottom, right, top

// Join multiple files.
var pdfA = pdfspin('1.pdf'), pdfB = pdfspin('2.pdf'), pdfC = pdfspin('3.pdf');
pdfspin.join(pdfA.page(1), pdfB, pdfC.pages(5, 10)).deflate().pdfStream()...
or
var docs= [pdfA.page(1), pdfB, pdfC.pages(5, 10)];
pdfspin.join(docs).deflate().pdfStream()...

// And output data as streams.
pdf.pdfStream().pipe(fs.createWriteStream('out.pdf')); // PDF of compiled output
pdf.pngStream(300).pipe(fs.createWriteStream('out-page1.png')); // PNG of first page at 300 dpi
pdf.textStream().pipe(process.stdout); // Individual text strings

// Extract content as text or images:
pdf.contentStream().on('data', console.log);
// { type: 'string', x: 1750, y: 594,
//   string: 'Reinhold Messner',
//   font: { height: 112, width: 116, font: 'ZSVUGH+Imago-Book' },
//   color: { r: 137, g: 123, b: 126 } }
// { type: 'image', x: 3049, y: 5680, width: 655, height: 810, index: 4 }

// Use the 'index' property of an image element to extract an image:
pdf.extractImageStream(0);

Repository

https://github.com/lpatters/pdfspin.git

Requirements

  • Install PDFTK (http://www.pdflabs.com/docs/install-pdftk/) on your system.
  • Ensure you have Ghostscript installed (check by running gs --version).
  • (optional) To extract individual images from a page, install pdfimages with brew install xpdf or apt-get install poppler-utils.

References

pdfspin's People

Contributors

lpatters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.