0.1.3 • Published 5 years ago

pdf-flatten v0.1.3

Weekly downloads
521
License
MIT
Repository
github
Last release
5 years ago

pdf-flatten

A nodejs module for flattening a PDF file.

This comes in handy when signatures, text, or images aren't sticking to a PDF file after using a tool to copy/convert a pdf like hummus or PDFTK.

Dependencies

  • GraphicsMagick

Note: Windows users, please be sure GraphicsMagick and Ghostscript are installed (see https://stackoverflow.com/questions/18733695/cimg-error-gm-exe-is-not-recognized-as-an-internal-or-external-command/45783910#45783910 for details) - then it works fine on Windows.

Ubuntu

sudo apt-get install graphicsmagick

OSX

brew install graphicsmagick

Installation

  $ [sudo] npm install pdf-flatten

Usage

const fs = require('fs');
const flattener = require('pdf-flatten');
 
const inputBuffer = fs.readFileSync(__dirname + '/test.pdf', err => { throw new Error(err) });
 
 // the flatten() method takes a buffer as an input
flattener.flatten(inputBuffer).then(res => {
  console.log(res) // output is the flattened pdf via a buffer as well
  fs.writeFileSync('outputFile.pdf', res, err => { throw new Error(err) });
})

Options

You can increase the conversion pixel density to your liking, the default is 200 if nothing is provided.

flattener.flatten(inputBuffer, {density: 600}).then(res => {
  console.log(res) // output is the flattened pdf via a buffer
  fs.writeFileSync('outputFile.pdf', res, err => { throw new Error(err) });
})

Maintainer

Josh Waite

License

MIT

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago