Constructor
new PdfTk(src)
PdfTk constructor.
Parameters:
Name | Type | Description |
---|---|---|
src |
Array | Input source file(s). |
Members
args :Array
Type:
- Array
command :String
Type:
- String
postArgs :Array
Type:
- Array
src :Array
Type:
- Array
tmpFiles :Array
Type:
- Array
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. |
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. |
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. |
Returns:
PdfTk class instance.
- Type
- Object
(static) isObject(item) → {Boolean}
Simple object check. Arrays not included.
Parameters:
Name | Type | Description |
---|---|---|
item |
Item to check. |
Returns:
Is object.
- Type
- Boolean
(static) isString(item) → {Boolean}
Simple string check.
Parameters:
Name | Type | Description |
---|---|---|
item |
Item to check. |
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. |
Returns:
Buffered file.
- Type
- Buffer
allow(perms) → {Object}
Set permissions for a PDF. By not passing in the "perms" parameter, you are disabling all features.
Parameters:
Name | Type | Description |
---|---|---|
perms |
Array | String | Permissions to set. Choices are: Printing, DegradedPrinting, ModifyContents, Assembly, CopyContents, ScreenReaders, ModifyAnnotations, FillIn, AllFeatures. |
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:
-
- https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-attach for more information.
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. |
Returns:
PdfTk class instance.
- Type
- Object
burst(outputOptions) → {Object}
Splits a single PDF into individual pages.
Parameters:
Name | Type | Description |
---|---|---|
outputOptions |
String | Array | Burst output options for naming conventions. |
Returns:
PdfTk class instance.
- Type
- Object
cat(catCommand) → {Object}
Assembles ("catenates") pages from input PDFs to create a new PDF.
Parameters:
Name | Type | Description |
---|---|---|
catCommand |
String | Array | Page ranges for cat method. |
Returns:
PdfTk class instance.
- Type
- Object
compress() → {Object}
Restore page sream compression.
Returns:
PdfTk class instance.
- Type
- Object
doAsk() → {Object}
Always prompt when errors occur.
Returns:
PdfTk class instance.
- Type
- Object
dontAsk() → {Object}
Never prompt when errors occur.
Returns:
PdfTk class instance.
- Type
- Object
dropXfa() → {Object}
Drop all XFA data.
Returns:
PdfTk class instance.
- Type
- Object
dumpData() → {Object}
Outputs PDF bookmarks and metadata.
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.
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. |
Returns:
PdfTk class instance.
- Type
- Object
flatten() → {Object}
Merge PDF form fields and their data.
Returns:
PdfTk class instance.
- Type
- Object
generateFdf() → {Object}
Generate fdf file from input PDF.
Returns:
PdfTk class instance.
- Type
- Object
inputPw(password) → {Object}
Set the input password.
Parameters:
Name | Type | Description |
---|---|---|
password |
String | Password to set. |
Returns:
PdfTk class instance.
- Type
- Object
keepFinalId() → {Object}
Keep final ID when combining pages.
Returns:
PdfTk class instance.
- Type
- Object
keepFirstId() → {Object}
Keep first ID when combining files.
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. |
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, outputDest) → {Promise}
Run the command.
Parameters:
Name | Type | 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 | 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. |
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. |
Returns:
PdfTk class instance.
- Type
- Object
shuffle(shuffleCommand) → {Object}
Collates pages from input PDF to create new PDF.
Parameters:
Name | Type | Description |
---|---|---|
shuffleCommand |
String | Array | Page ranges for shuffle method. |
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. |
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. |
Returns:
PdfTk class instance.
- Type
- Object
uncompress() → {Object}
Remove page stream compression.
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:
-
- https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-unpack for more information.
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. |
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.
Returns:
PdfTk class instance.
- Type
- Object