Node PDFBox
node-pdfbox is a bridge library to manipulate PDF based on PDFBox (https://pdfbox.apache.org/)
Installation
Dependencies
This module require JVM configured on host machine to work. When you use this module with nw.js you need to specify this requisite on installation process.
You can use node-pdfbox with NW.js, but don't forget to install JDK to compile java module, after that you can distribute you app in a machine with JVM installed.
npm install --save node-pdfbox
Quick Examples
If you want to call async operations just use the method without Sync suffix.
Sync
page;
Async
page ;
Basic operations
let Document = ; let document = Document;let page = document;let image = page;let imageScaled = page;let imageScaledToFill = page; let newDocument = page;newDocument;newDocument; image;image;image;image; image;
or
Document;
Get information
let title = document;let title1 = document; //The same of getInfolet author = document;let subject = document;let keywords = document;
Number of pages
let numberOfPages = document;
Add pages to document
document; //PDFPage to end of filedocument; // add page (second) from path (first) at index (third) document; //Copy all pages from path to end of documentdocument; //Copy all pages from PDFDocumentdocument; //atIndexdocument; //start, end, atIndex
Save document
document; //save current documentdocument //save as
Get page
let page = document;
Get crop box rect
page;
Get scale to fill
page; //width, height
Get scale to fit
page; //width, height
Get text
page;
Extract page
let doc = page;
Create image
const scale = 2; let image = page;let image1 = page; //scaledlet image2 = page; //width, height - crop on center
Fit image
image;
Crop image
image;
Save image
image;
Known issues
Before install this module, check whether jvm is installed. To compile this module you need to install JDK.
Not implemented yet
- Working with Encrypting and signing PDFs
- Support to create PDF