Class: PdfTk

PdfTk(src, tmpFilesopt)

PdfTk Class

Constructor

new PdfTk(src, tmpFilesopt)

PdfTk constructor.
Parameters:
Name Type Attributes Description
src Array Input source file(s).
tmpFiles Array <optional>
Array of temp files that have been created while initializing the constructor.
Source:

Members

args :Array

Type:
  • Array
Source:

command :String

Type:
  • String
Source:

postArgs :Array

Type:
  • Array
Source:

src :Array

Type:
  • Array
Source:

tmpFiles :Array

Type:
  • Array
Source:

Methods

(static) generateFdfFromJSON(data) → {Buffer}

Creates fdf file from JSON input. Converts input values to binary buffer, which seems to allow PdfTk to render utf-8 characters.
Parameters:
Name Type Description
data Object JSON data to transform to fdf.
Source:
Returns:
Fdf data as a buffer.
Type
Buffer

(static) generateInfoFromJSON(data) → {Buffer}

Creates pdf info text file from JSON input.
Parameters:
Name Type Description
data Object JSON data to transform to info file.
Source:
Returns:
Info text file as a buffer.
Type
Buffer

(static) input(src) → {Object}

Input files and initialize plugin.
Parameters:
Name Type Description
src String | Array Source files to input.
Source:
Returns:
PdfTk class instance.
Type
Object

(static) isObject(item) → {Boolean}

Simple object check. Arrays not included.
Parameters:
Name Type Description
item Item to check.
Source:
Returns:
Is object.
Type
Boolean

(static) isString(item) → {Boolean}

Simple string check.
Parameters:
Name Type Description
item Item to check.
Source:
Returns:
Is string.
Type
Boolean

(static) toBuffer(file) → {Buffer}

Returns a buffer from a file.
Parameters:
Name Type Description
file String | Buffer File to buffer.
Source:
Returns:
Buffered file.
Type
Buffer

allow(permsopt) → {Object}

Set permissions for a PDF. By not passing in the "perms" parameter, you are disabling all features.
Parameters:
Name Type Attributes Description
perms Array | String <optional>
Permissions to set. Choices are: Printing, DegradedPrinting, ModifyContents, Assembly, CopyContents, ScreenReaders, ModifyAnnotations, FillIn, AllFeatures. Passing no arguments will disable all.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

attachFiles(files) → {Object}

Attach files to PDF.
Parameters:
Name Type Description
files String | Array Files to attach.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

background(file) → {Object}

Applies a PDF watermark to the background of a single PDF.
Parameters:
Name Type Description
file String | Buffer PDF file that contains the background to be applied.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

burst(outputOptionsopt) → {Object}

Splits a single PDF into individual pages.
Parameters:
Name Type Attributes Description
outputOptions String <optional>
Burst output options for naming conventions.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

cat(catCommandopt) → {Object}

Assembles ("catenates") pages from input PDFs to create a new PDF.
Parameters:
Name Type Attributes Description
catCommand String | Array <optional>
Page ranges for cat method.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

compress() → {Object}

Restore page sream compression.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

doAsk() → {Object}

Always prompt when errors occur.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dontAsk() → {Object}

Never prompt when errors occur.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dropXfa() → {Object}

Drop all XFA data.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dumpData() → {Object}

Outputs PDF bookmarks and metadata.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dumpDataAnnots() → {Object}

Outputs PDF annotation information.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dumpDataFields() → {Object}

Outputs form field statistics.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dumpDataFieldsUtf8() → {Object}

Outputs form field statistics with utf-8 encoding.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

dumpDataUtf8() → {Object}

Outputs PDF bookmarks and metadata with utf-8 encoding.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

encrypt40Bit() → {Object}

Set 40 bit encryption.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

encrypt128Bit() → {Object}

Set 128 bit encryption.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

fillForm(data) → {Object}

Fill a PDF form from JSON data.
Parameters:
Name Type Description
data Object Form fill data.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

flatten() → {Object}

Merge PDF form fields and their data.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

generateFdf() → {Object}

Generate fdf file from input PDF.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

ignoreWarnings() → {Object}

Allows the plugin to ignore the PDFTK warnings. Useful with huge PDF files.
Source:
Returns:
PdfTk class instance.
Type
Object

inputPw(password) → {Object}

Set the input password.
Parameters:
Name Type Description
password String Password to set.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

keepFinalId() → {Object}

Keep final ID when combining pages.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

keepFirstId() → {Object}

Keep first ID when combining files.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

multiBackground(file) → {Object}

Same as the background operation, but applies each page of the background PDF to the corresponding page of the input PDF.
Parameters:
Name Type Description
file String | Buffer PDF file that contains the background to be applied.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

multiStamp(file) → {Object}

Same as the stamp operation, but applies each page of the stamp PDF to the corresponding page of the input PDF.
Parameters:
Name Type Description
file String | Buffer PDF file that contains the content to be stamped.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

needAppearances() → {Object}

Set Adobe Reader to generate new field appearances.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

output(writeFile, outputDestopt, needsOutputopt) → {Promise}

Run the command.
Parameters:
Name Type Attributes Default Description
writeFile String Path to the output file to write from stdout. If used with the "outputDest" parameter, two files will be written.
outputDest String <optional>
The output file to write without stdout. When present, the returning promise will not contain the output buffer. If used with the "writeFile" parameter, two files will be written.
needsOutput Boolean <optional>
true Optional boolean used to disclude the 'output' argument (only used for specific methods).
Source:
Returns:
Promise that resolves the output buffer, if "outputDest" is not given.
Type
Promise

ownerPw(password) → {Object}

Set the owner password.
Parameters:
Name Type Description
password String Password to set.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

rotate(rotateCommand) → {Object}

Takes a single input PDF and rotates just the specified pages.
Parameters:
Name Type Description
rotateCommand String | Array Page ranges for rotate command.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

shuffle(shuffleCommandopt) → {Object}

Collates pages from input PDF to create new PDF.
Parameters:
Name Type Attributes Description
shuffleCommand String | Array <optional>
Page ranges for shuffle method.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

stamp(file) → {Object}

This behaves just like the background operation except it overlays the stamp PDF page on top of the input PDF document’s pages.
Parameters:
Name Type Description
file String | Buffer PDF file that contains the content to be stamped.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

toPage(pageNo) → {Object}

Used with the attachFiles method to attach to a specific page.
Parameters:
Name Type Description
pageNo Number Page number in which to attach.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

uncompress() → {Object}

Remove page stream compression.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

unpackFiles(outputDir) → {Promise}

Unpack files into an output directory. This method is not chainable, and hereby does not require the output method afterwards.
Parameters:
Name Type Description
outputDir String Output directory for files.
Source:
See:
Returns:
Promise callback
Type
Promise

updateInfo(data) → {Object}

Update the bookmarks and metadata of a PDF with utf-8 encoding.
Parameters:
Name Type Description
data Object Update data.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

updateInfoUtf8(data) → {Object}

Update the bookmarks and metadata of a PDF.
Parameters:
Name Type Description
data Object Update data.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

userPw(password) → {Object}

Set the user password.
Parameters:
Name Type Description
password String Password to set.
Source:
See:
Returns:
PdfTk class instance.
Type
Object

verbose() → {Object}

Set the verbose option.
Source:
See:
Returns:
PdfTk class instance.
Type
Object