node-poppler 6.2.6 → 6.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/index.js +259 -258
- package/types/index.d.ts +560 -266
package/src/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const camelCase = require("camelcase");
|
|
4
|
-
const path = require("upath");
|
|
5
3
|
const { execFile, spawn } = require("child_process");
|
|
6
4
|
const { promisify } = require("util");
|
|
5
|
+
const camelCase = require("camelcase");
|
|
6
|
+
const { lt } = require("semver");
|
|
7
|
+
const path = require("upath");
|
|
7
8
|
|
|
8
9
|
const execFileAsync = promisify(execFile);
|
|
9
10
|
|
|
@@ -24,8 +25,8 @@ const errorMessages = {
|
|
|
24
25
|
* @ignore
|
|
25
26
|
* @param {object} acceptedOptions - Object containing options that a binary accepts.
|
|
26
27
|
* @param {object} options - Object containing options to pass to binary.
|
|
27
|
-
* @param {string
|
|
28
|
-
* @returns {
|
|
28
|
+
* @param {string} [version] - Version of binary.
|
|
29
|
+
* @returns {string[]} Array of CLI arguments.
|
|
29
30
|
* @throws If invalid arguments provided.
|
|
30
31
|
*/
|
|
31
32
|
function parseOptions(acceptedOptions, options, version) {
|
|
@@ -58,7 +59,7 @@ function parseOptions(acceptedOptions, options, version) {
|
|
|
58
59
|
if (
|
|
59
60
|
acceptedOptions[key].minVersion &&
|
|
60
61
|
version &&
|
|
61
|
-
version
|
|
62
|
+
lt(version, acceptedOptions[key].minVersion, { loose: true })
|
|
62
63
|
) {
|
|
63
64
|
invalidArgs.push(
|
|
64
65
|
`Invalid option provided for the current version of the binary used. '${key}' was introduced in v${acceptedOptions[key].minVersion}, but received v${version}`
|
|
@@ -76,7 +77,7 @@ function parseOptions(acceptedOptions, options, version) {
|
|
|
76
77
|
|
|
77
78
|
class Poppler {
|
|
78
79
|
/**
|
|
79
|
-
* @param {string
|
|
80
|
+
* @param {string} [binPath] - Path of poppler-utils binaries.
|
|
80
81
|
*/
|
|
81
82
|
constructor(binPath) {
|
|
82
83
|
if (binPath) {
|
|
@@ -103,9 +104,9 @@ class Poppler {
|
|
|
103
104
|
* @param {string} file - Filepath of the PDF file to read.
|
|
104
105
|
* @param {string} fileToAttach - Filepath of the attachment to be embedded into the PDF file.
|
|
105
106
|
* @param {string} outputFile - Filepath of the file to output the results to.
|
|
106
|
-
* @param {object
|
|
107
|
-
* @param {boolean
|
|
108
|
-
* @param {boolean
|
|
107
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
108
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
109
|
+
* @param {boolean} [options.replace] - Replace embedded file with same name (if it exists).
|
|
109
110
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
110
111
|
*/
|
|
111
112
|
async pdfAttach(file, fileToAttach, outputFile, options = {}) {
|
|
@@ -134,26 +135,26 @@ class Poppler {
|
|
|
134
135
|
* @author Frazer Smith
|
|
135
136
|
* @description Lists or extracts embedded files (attachments) from a PDF file.
|
|
136
137
|
* @param {string} file - Filepath of the PDF file to read.
|
|
137
|
-
* @param {object
|
|
138
|
-
* @param {boolean
|
|
138
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
139
|
+
* @param {boolean} [options.listEmbedded] - List all of the embedded files in the PDF file.
|
|
139
140
|
* File names are converted to the text encoding specified by `options.outputEncoding`.
|
|
140
|
-
* @param {string
|
|
141
|
-
* @param {string
|
|
141
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
142
|
+
* @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
|
|
142
143
|
* This defaults to `UTF-8`.
|
|
143
|
-
* @param {string
|
|
144
|
+
* @param {string} [options.outputPath] - Set the file name used when saving an embedded file with
|
|
144
145
|
* the save option enabled, or the directory if `options.saveall` is used.
|
|
145
|
-
* @param {boolean
|
|
146
|
-
* @param {boolean
|
|
146
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
147
|
+
* @param {boolean} [options.saveAllFiles] - Save all of the embedded files. This uses the file
|
|
147
148
|
* names associated with the embedded files (as printed by `options.listEmbedded`).
|
|
148
149
|
* By default, the files are saved in the current directory; this can be changed
|
|
149
150
|
* with `options.outputPath`.
|
|
150
|
-
* @param {string
|
|
151
|
+
* @param {string} [options.saveFile] - Save the specified embedded file.
|
|
151
152
|
* By default, this uses the file name associated with the embedded file (as printed by
|
|
152
153
|
* `options.listEmbedded`); the file name can be changed with `options.outputPath`.
|
|
153
|
-
* @param {number
|
|
154
|
+
* @param {number} [options.saveSpecificFile] - Save the specified embedded file.
|
|
154
155
|
* By default, this uses the file name associated with the embedded file (as printed by
|
|
155
156
|
* `options.listEmbedded`); the file name can be changed with `options.outputPath`.
|
|
156
|
-
* @param {string
|
|
157
|
+
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
157
158
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
158
159
|
*/
|
|
159
160
|
async pdfDetach(file, options = {}) {
|
|
@@ -190,15 +191,15 @@ class Poppler {
|
|
|
190
191
|
/**
|
|
191
192
|
* @author Frazer Smith
|
|
192
193
|
* @description Lists the fonts used in a PDF file along with various information for each font.
|
|
193
|
-
* @param {Buffer|
|
|
194
|
-
* @param {object
|
|
195
|
-
* @param {number
|
|
196
|
-
* @param {number
|
|
197
|
-
* @param {boolean
|
|
194
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
195
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
196
|
+
* @param {number} [options.firstPageToExamine] - Specifies the first page to examine.
|
|
197
|
+
* @param {number} [options.lastPageToExamine] - Specifies the last page to examine.
|
|
198
|
+
* @param {boolean} [options.listSubstitutes] - List the substitute fonts that poppler
|
|
198
199
|
* will use for non-embedded fonts.
|
|
199
|
-
* @param {string
|
|
200
|
-
* @param {boolean
|
|
201
|
-
* @param {string
|
|
200
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
201
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
202
|
+
* @param {string} [options.userPassword] - User password (for encrypted files). *
|
|
202
203
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
203
204
|
*/
|
|
204
205
|
async pdfFonts(file, options = {}) {
|
|
@@ -265,25 +266,25 @@ class Poppler {
|
|
|
265
266
|
/**
|
|
266
267
|
* @author Frazer Smith
|
|
267
268
|
* @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files.
|
|
268
|
-
* @param {Buffer|
|
|
269
|
-
* @param {string
|
|
270
|
-
* @param {object
|
|
271
|
-
* @param {boolean
|
|
269
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
270
|
+
* @param {string} [outputPrefix] - Filename prefix of output files.
|
|
271
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
272
|
+
* @param {boolean} [options.allFiles] - Write JPEG, JPEG2000, JBIG2, and CCITT images in their native format.
|
|
272
273
|
* CMYK files are written as TIFF files. All other images are written as PNG files.
|
|
273
|
-
* @param {boolean
|
|
274
|
-
* @param {number
|
|
275
|
-
* @param {number
|
|
276
|
-
* @param {boolean
|
|
274
|
+
* @param {boolean} [options.ccittFile] - Generate CCITT images as CCITT files.
|
|
275
|
+
* @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
|
|
276
|
+
* @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
|
|
277
|
+
* @param {boolean} [options.list] - Instead of writing the images, list the
|
|
277
278
|
* images along with various information for each image.
|
|
278
279
|
* NOTE: Do not specify the outputPrefix with this option.
|
|
279
|
-
* @param {boolean
|
|
280
|
-
* @param {boolean
|
|
281
|
-
* @param {boolean
|
|
282
|
-
* @param {string
|
|
283
|
-
* @param {boolean
|
|
284
|
-
* @param {boolean
|
|
285
|
-
* @param {boolean
|
|
286
|
-
* @param {string
|
|
280
|
+
* @param {boolean} [options.jbig2File] - Generate JBIG2 images as JBIG2 files.
|
|
281
|
+
* @param {boolean} [options.jpeg2000File] - Generate JPEG2000 images at JP2 files.
|
|
282
|
+
* @param {boolean} [options.jpegFile] - Generate JPEG images as JPEG files.
|
|
283
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
284
|
+
* @param {boolean} [options.pngFile] - Change the default output format to PNG.
|
|
285
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
286
|
+
* @param {boolean} [options.tiffFile] - Change the default output format to TIFF.
|
|
287
|
+
* @param {string} [options.userPassword] - Specify the user password for the PDF file.
|
|
287
288
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
288
289
|
*/
|
|
289
290
|
async pdfImages(file, outputPrefix, options = {}) {
|
|
@@ -366,35 +367,35 @@ class Poppler {
|
|
|
366
367
|
/**
|
|
367
368
|
* @author Frazer Smith
|
|
368
369
|
* @description Prints the contents of the `Info` dictionary from a PDF file.
|
|
369
|
-
* @param {Buffer|
|
|
370
|
-
* @param {object
|
|
371
|
-
* @param {number
|
|
372
|
-
* @param {number
|
|
373
|
-
* @param {boolean
|
|
374
|
-
* @param {string
|
|
370
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
371
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
372
|
+
* @param {number} [options.firstPageToConvert] - First page to print.
|
|
373
|
+
* @param {number} [options.lastPageToConvert] - Last page to print.
|
|
374
|
+
* @param {boolean} [options.listEncodingOptions] - List the available encodings.
|
|
375
|
+
* @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
|
|
375
376
|
* This defaults to `UTF-8`.
|
|
376
|
-
* @param {string
|
|
377
|
-
* @param {boolean
|
|
378
|
-
* @param {boolean
|
|
377
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
378
|
+
* @param {boolean} [options.printAsJson] - Print result as a JSON object.
|
|
379
|
+
* @param {boolean} [options.printBoundingBoxes] - Prints the page box bounding boxes:
|
|
379
380
|
* MediaBox, CropBox, BleedBox, TrimBox, and ArtBox.
|
|
380
|
-
* @param {boolean
|
|
381
|
+
* @param {boolean} [options.printDocStruct] - Prints the logical document structure
|
|
381
382
|
* of a Tagged-PDF file.
|
|
382
|
-
* @param {boolean
|
|
383
|
+
* @param {boolean} [options.printDocStructText] - Print the textual content along with the
|
|
383
384
|
* document structure of a Tagged-PDF file. Note that extracting text this way might be slow
|
|
384
385
|
*
|
|
385
386
|
* for big PDF files.
|
|
386
|
-
* @param {boolean
|
|
387
|
-
* @param {boolean
|
|
388
|
-
* @param {boolean
|
|
387
|
+
* @param {boolean} [options.printIsoDates] - Prints dates in ISO-8601 format (including the time zone).
|
|
388
|
+
* @param {boolean} [options.printJS] - Prints all JavaScript in the PDF file.
|
|
389
|
+
* @param {boolean} [options.printMetadata] - Prints document-level metadata. (This is the `Metadata`
|
|
389
390
|
* stream from the PDF file's Catalog object).
|
|
390
|
-
* @param {boolean
|
|
391
|
+
* @param {boolean} [options.printNamedDests] - Print a list of all named destinations. If a page range
|
|
391
392
|
* is specified using the `options.firstPageToConvert` and `options.lastPageToConvert` options, only destinations
|
|
392
393
|
* in the page range are listed.
|
|
393
|
-
* @param {boolean
|
|
394
|
-
* @param {boolean
|
|
394
|
+
* @param {boolean} [options.printRawDates] - Prints the raw (undecoded) date strings, directly from the PDF file.
|
|
395
|
+
* @param {boolean} [options.printUrls] - Print all URLs in the PDF; only URLs referenced by PDF objects
|
|
395
396
|
* such as Link Annotations are listed, not URL strings in the text content.
|
|
396
|
-
* @param {boolean
|
|
397
|
-
* @param {string
|
|
397
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
398
|
+
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
398
399
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
399
400
|
*/
|
|
400
401
|
async pdfInfo(file, options = {}) {
|
|
@@ -507,12 +508,12 @@ class Poppler {
|
|
|
507
508
|
* @param {string} outputPattern - Should contain %d (or any variant respecting printf format),
|
|
508
509
|
* since %d is replaced by the page number.
|
|
509
510
|
* As an example, `sample-%d.pdf` will produce `sample-1.pdf` for a single page document.
|
|
510
|
-
* @param {object
|
|
511
|
-
* @param {number
|
|
511
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
512
|
+
* @param {number} [options.firstPageToExtract] - Specifies the first page to extract.
|
|
512
513
|
* This defaults to page 1.
|
|
513
|
-
* @param {number
|
|
514
|
+
* @param {number} [options.lastPageToExtract] - Specifies the last page to extract.
|
|
514
515
|
* This defaults to the last page of the PDF file.
|
|
515
|
-
* @param {boolean
|
|
516
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
516
517
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
517
518
|
*/
|
|
518
519
|
async pdfSeparate(file, outputPattern, options = {}) {
|
|
@@ -547,45 +548,45 @@ class Poppler {
|
|
|
547
548
|
/**
|
|
548
549
|
* @author Frazer Smith
|
|
549
550
|
* @description Converts a PDF file to EPS/JPEG/PDF/PNG/PS/SVG/TIFF.
|
|
550
|
-
* @param {Buffer|
|
|
551
|
-
* @param {string
|
|
551
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
552
|
+
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
552
553
|
*
|
|
553
554
|
* If `undefined` then will write output to stdout. Using stdout is not valid with image formats
|
|
554
555
|
* (jpeg, png, and tiff) unless `options.singleFile` is set to `true`.
|
|
555
556
|
* Encoding is set to `binary` if used with `options.singleFile` or `options.pdfFile`.
|
|
556
557
|
*
|
|
557
558
|
* If not set then the output filename will be derived from the PDF file name.
|
|
558
|
-
* @param {object
|
|
559
|
-
* @param {('
|
|
559
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
560
|
+
* @param {('best'|'default'|'fast'|'good'|'gray'|'none'|'subpixel')} [options.antialias] - Set the cairo
|
|
560
561
|
* antialias option used for text and drawing in image files (or rasterized regions in vector output).
|
|
561
|
-
* @param {boolean
|
|
562
|
+
* @param {boolean} [options.cropBox] - Uses the crop box rather than media box when
|
|
562
563
|
* generating the files (PNG/JPEG/TIFF only).
|
|
563
|
-
* @param {number
|
|
564
|
+
* @param {number} [options.cropHeight] - Specifies the height of crop area in pixels
|
|
564
565
|
* (image output) or points (vector output).
|
|
565
|
-
* @param {number
|
|
566
|
+
* @param {number} [options.cropSize] - Specifies the size of crop square in pixels
|
|
566
567
|
* (image output) or points (vector output).
|
|
567
|
-
* @param {number
|
|
568
|
+
* @param {number} [options.cropWidth] - Specifies the width of crop area in pixels
|
|
568
569
|
* (image output) or points (vector output).
|
|
569
|
-
* @param {number
|
|
570
|
+
* @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left
|
|
570
571
|
* corner in pixels (image output) or points (vector output).
|
|
571
|
-
* @param {number
|
|
572
|
+
* @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left
|
|
572
573
|
* corner in pixels (image output) or points (vector output).
|
|
573
|
-
* @param {boolean
|
|
574
|
+
* @param {boolean} [options.duplex] - Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC
|
|
574
575
|
* comment to the PostScript file (PS only). This tells the print manager to enable duplexing.
|
|
575
|
-
* @param {boolean
|
|
576
|
+
* @param {boolean} [options.epsFile] - Generate an EPS file. An EPS file contains a single image,
|
|
576
577
|
* so if you use this option with a multi-page PDF file, you must use `options.firstPageToConvert` and
|
|
577
578
|
* `options.lastPageToConvert` to specify a single page.
|
|
578
579
|
* The page size options (originalPageSizes, paperSize, paperWidth, paperHeight) can not be used
|
|
579
580
|
* with this option.
|
|
580
|
-
* @param {boolean
|
|
581
|
-
* @param {boolean
|
|
581
|
+
* @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages.
|
|
582
|
+
* @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the
|
|
582
583
|
* paper (PS,PDF,SVG only). By default, these pages are not scaled.
|
|
583
|
-
* @param {number
|
|
584
|
-
* @param {boolean
|
|
585
|
-
* @param {string
|
|
584
|
+
* @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
|
|
585
|
+
* @param {boolean} [options.grayscaleFile] - Generate grayscale file (PNG, JPEG, and TIFF only).
|
|
586
|
+
* @param {string} [options.iccFile] - Use the specified ICC file as the output profile
|
|
586
587
|
* (PNG only). The profile will be embedded in the PNG file.
|
|
587
|
-
* @param {boolean
|
|
588
|
-
* @param {string
|
|
588
|
+
* @param {boolean} [options.jpegFile] - Generate JPEG file(s).
|
|
589
|
+
* @param {string} [options.jpegOptions] - When used with `options.jpegFile`, this option can
|
|
589
590
|
* be used to control the JPEG compression parameters. It takes a string of the form
|
|
590
591
|
* `"<opt>=<val>[,<opt>=<val>]"`. Currently available options are:
|
|
591
592
|
* - `quality` Selects the JPEG quality value. The value must be an integer between 0 and 100.
|
|
@@ -596,57 +597,57 @@ class Poppler {
|
|
|
596
597
|
* with "y" performing optimization, otherwise the default Huffman tables are used.
|
|
597
598
|
*
|
|
598
599
|
* Example: `"quality=95,optimize=y"`.
|
|
599
|
-
* @param {number
|
|
600
|
-
* @param {boolean
|
|
601
|
-
* @param {boolean
|
|
600
|
+
* @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
|
|
601
|
+
* @param {boolean} [options.monochromeFile] - Generate monochrome file (PNG and TIFF only).
|
|
602
|
+
* @param {boolean} [options.noCenter] - By default, PDF pages smaller than the paper
|
|
602
603
|
* (after any scaling) are centered on the paper. This option causes them to be aligned to
|
|
603
604
|
* the lower-left corner of the paper instead (PS,PDF,SVG only).
|
|
604
|
-
* @param {boolean
|
|
605
|
+
* @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox
|
|
605
606
|
* specified in the PDF file. This option disables cropping (PS, PDF, SVG only).
|
|
606
|
-
* @param {boolean
|
|
607
|
+
* @param {boolean} [options.noShrink] - Do not scale PDF pages which are larger than the paper
|
|
607
608
|
* (PS,PDF,SVG only). By default, pages larger than the paper are shrunk to fit.
|
|
608
|
-
* @param {boolean
|
|
609
|
-
* @param {boolean
|
|
609
|
+
* @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages.
|
|
610
|
+
* @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match
|
|
610
611
|
* the size specified in the PDF file.
|
|
611
|
-
* @param {string
|
|
612
|
+
* @param {string} [options.ownerPassword] - Specify the owner password for the PDF file.
|
|
612
613
|
* Providing this will bypass all security restrictions.
|
|
613
|
-
* @param {number
|
|
614
|
-
* @param {('
|
|
615
|
-
* or `
|
|
614
|
+
* @param {number} [options.paperHeight] - Set the paper height, in points (PS, PDF, SVG only).
|
|
615
|
+
* @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - Set the paper size to one of `A3`, `A4`,
|
|
616
|
+
* `legal`, or `letter` (PS,PDF,SVG only). This can also be set to `match`, which will set the paper size
|
|
616
617
|
* of each page to match the size specified in the PDF file. If none of the paperSize,
|
|
617
618
|
* paperWidth, or paperHeight options are specified the default is to match the paper size.
|
|
618
|
-
* @param {number
|
|
619
|
-
* @param {boolean
|
|
620
|
-
* @param {boolean
|
|
621
|
-
* @param {boolean
|
|
622
|
-
* @param {boolean
|
|
623
|
-
* @param {boolean
|
|
624
|
-
* @param {boolean
|
|
619
|
+
* @param {number} [options.paperWidth] - Set the paper width, in points (PS,PDF,SVG only).
|
|
620
|
+
* @param {boolean} [options.pdfFile] - Generate PDF file.
|
|
621
|
+
* @param {boolean} [options.pngFile] - Generate PNG file(s).
|
|
622
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version information.
|
|
623
|
+
* @param {boolean} [options.psFile] - Generate PS file.
|
|
624
|
+
* @param {boolean} [options.psLevel2] - Generate Level 2 PostScript (PS only).
|
|
625
|
+
* @param {boolean} [options.psLevel3] - Generate Level 3 PostScript (PS only). This enables all
|
|
625
626
|
* Level 2 features plus shading patterns and masked images. This is the default setting.
|
|
626
|
-
* @param {boolean
|
|
627
|
-
* @param {number
|
|
627
|
+
* @param {boolean} [options.quiet] - Do not print any messages or errors.
|
|
628
|
+
* @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of
|
|
628
629
|
* image files (or rasterized regions in vector output). The default is 150 PPI.
|
|
629
|
-
* @param {number
|
|
630
|
+
* @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per
|
|
630
631
|
* inch of image files (or rasterized regions in vector output). The default is 150 PPI.
|
|
631
|
-
* @param {number
|
|
632
|
+
* @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of
|
|
632
633
|
* image files (or rasterized regions in vector output). The default is 150 PPI.
|
|
633
|
-
* @param {number
|
|
634
|
+
* @param {number} [options.scalePageTo] - Scales the long side of each page (width for landscape
|
|
634
635
|
* pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will
|
|
635
636
|
* be determined by the aspect ratio of the page (PNG/JPEG/TIFF only).
|
|
636
|
-
* @param {number
|
|
637
|
+
* @param {number} [options.scalePageToXAxis] - Scales each page horizontally to fit in scale-to-x
|
|
637
638
|
* pixels. If scale-to-y is set to -1, the vertical size will determined by the aspect ratio of
|
|
638
639
|
* the page (PNG/JPEG/TIFF only).
|
|
639
|
-
* @param {number
|
|
640
|
+
* @param {number} [options.scalePageToYAxis] - Scales each page vertically to fit in scale-to-y
|
|
640
641
|
* pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio of
|
|
641
642
|
* the page (PNG/JPEG/TIFF only).
|
|
642
|
-
* @param {boolean
|
|
643
|
+
* @param {boolean} [options.singleFile] - Writes only the first page and does not add digits.
|
|
643
644
|
* Can only be used with `options.jpegFile`, `options.pngFile`, and `options.tiffFile`.
|
|
644
|
-
* @param {boolean
|
|
645
|
-
* @param {('
|
|
646
|
-
* @param {boolean
|
|
647
|
-
* @param {boolean
|
|
645
|
+
* @param {boolean} [options.svgFile] - Generate SVG (Scalable Vector Graphics) file.
|
|
646
|
+
* @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression.
|
|
647
|
+
* @param {boolean} [options.tiffFile] - Generate TIFF file(s).
|
|
648
|
+
* @param {boolean} [options.transparentPageColor] - Use a transparent page color
|
|
648
649
|
* instead of white (PNG and TIFF only).
|
|
649
|
-
* @param {string
|
|
650
|
+
* @param {string} [options.userPassword] - Specify the user password for the PDF file.
|
|
650
651
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
651
652
|
*/
|
|
652
653
|
async pdfToCairo(file, outputFile, options = {}) {
|
|
@@ -771,41 +772,41 @@ class Poppler {
|
|
|
771
772
|
/**
|
|
772
773
|
* @author Frazer Smith
|
|
773
774
|
* @description Converts a PDF file to HTML.
|
|
774
|
-
* @param {Buffer|
|
|
775
|
-
* @param {string
|
|
775
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
776
|
+
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
776
777
|
* If `undefined` then Poppler will use the directory and name of the original file
|
|
777
778
|
* and create a new file, with `-html` appended to the end of the filename.
|
|
778
779
|
*
|
|
779
780
|
* Required if `file` is a Buffer.
|
|
780
|
-
* @param {object
|
|
781
|
-
* @param {boolean
|
|
782
|
-
* @param {boolean
|
|
783
|
-
* @param {boolean
|
|
784
|
-
* @param {boolean
|
|
785
|
-
* @param {number
|
|
786
|
-
* @param {boolean
|
|
787
|
-
* @param {boolean
|
|
788
|
-
* @param {('
|
|
781
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
782
|
+
* @param {boolean} [options.complexOutput] - Generate complex output.
|
|
783
|
+
* @param {boolean} [options.dataUrls] - Use data URLs instead of external images in HTML.
|
|
784
|
+
* @param {boolean} [options.exchangePdfLinks] - Exchange .pdf links with .html.
|
|
785
|
+
* @param {boolean} [options.extractHidden] - Force hidden text extraction.
|
|
786
|
+
* @param {number} [options.firstPageToConvert] - First page to print.
|
|
787
|
+
* @param {boolean} [options.fontFullName] - Outputs the font name without any substitutions.
|
|
788
|
+
* @param {boolean} [options.ignoreImages] - Ignore images.
|
|
789
|
+
* @param {('JPG'|'PNG')} [options.imageFormat] - Image file format for Splash output (JPG or PNG).
|
|
789
790
|
* If complexOutput is selected, but imageFormat is not specified, PNG will be assumed.
|
|
790
|
-
* @param {number
|
|
791
|
-
* @param {boolean
|
|
792
|
-
* @param {boolean
|
|
793
|
-
* @param {boolean
|
|
794
|
-
* @param {boolean
|
|
791
|
+
* @param {number} [options.lastPageToConvert] - Last page to print.
|
|
792
|
+
* @param {boolean} [options.noDrm] - Override document DRM settings.
|
|
793
|
+
* @param {boolean} [options.noFrames] - Generate no frames. Not supported in complex output mode.
|
|
794
|
+
* @param {boolean} [options.noMergeParagraph] - Do not merge paragraphs.
|
|
795
|
+
* @param {boolean} [options.noRoundedCoordinates] - Do not round coordinates
|
|
795
796
|
* (with XML output only).
|
|
796
|
-
* @param {string
|
|
797
|
+
* @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
|
|
797
798
|
* This defaults to `UTF-8`.
|
|
798
|
-
* @param {string
|
|
799
|
-
* @param {boolean
|
|
800
|
-
* @param {boolean
|
|
801
|
-
* @param {boolean
|
|
802
|
-
* @param {boolean
|
|
803
|
-
* @param {string
|
|
804
|
-
* @param {number
|
|
799
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
800
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version info.
|
|
801
|
+
* @param {boolean} [options.quiet] - Do not print any messages or errors.
|
|
802
|
+
* @param {boolean} [options.singlePage] - generate single HTML that includes all pages.
|
|
803
|
+
* @param {boolean} [options.stdout] - Use standard output.
|
|
804
|
+
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
805
|
+
* @param {number} [options.wordBreakThreshold] - Adjust the word break threshold percent.
|
|
805
806
|
* Default is 10. Word break occurs when distance between two adjacent characters is greater
|
|
806
807
|
* than this percent of character height.
|
|
807
|
-
* @param {boolean
|
|
808
|
-
* @param {number
|
|
808
|
+
* @param {boolean} [options.xmlOutput] - Output for XML post-processing.
|
|
809
|
+
* @param {number} [options.zoom] - Zoom the PDF document (default 1.5).
|
|
809
810
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
810
811
|
*/
|
|
811
812
|
async pdfToHtml(file, outputFile, options = {}) {
|
|
@@ -903,73 +904,73 @@ class Poppler {
|
|
|
903
904
|
* @description Converts a PDF file to colour image files in Portable Pixmap (PPM) format,
|
|
904
905
|
* grayscale image files in Portable Graymap (PGM) format, or monochrome image files
|
|
905
906
|
* in Portable Bitmap (PBM) format.
|
|
906
|
-
* @param {Buffer|
|
|
907
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
907
908
|
* @param {string} outputPath - Filepath to output the results to.
|
|
908
|
-
* @param {object
|
|
909
|
-
* @param {('
|
|
909
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
910
|
+
* @param {('no'|'yes')} [options.antialiasFonts] - Enable or disable font anti-aliasing.
|
|
910
911
|
* This defaults to `yes`.
|
|
911
|
-
* @param {('
|
|
912
|
+
* @param {('no'|'yes')} [options.antialiasVectors] - Enable or disable vector anti-aliasing.
|
|
912
913
|
* This defaults to `yes`.
|
|
913
|
-
* @param {boolean
|
|
914
|
+
* @param {boolean} [options.cropBox] - Uses the crop box rather than media box when
|
|
914
915
|
* generating the files (PNG/JPEG/TIFF only).
|
|
915
|
-
* @param {number
|
|
916
|
+
* @param {number} [options.cropHeight] - Specifies the height of crop area in pixels
|
|
916
917
|
* (image output) or points (vector output).
|
|
917
|
-
* @param {number
|
|
918
|
+
* @param {number} [options.cropSize] - Specifies the size of crop square in pixels
|
|
918
919
|
* (image output) or points (vector output).
|
|
919
|
-
* @param {number
|
|
920
|
+
* @param {number} [options.cropWidth] - Specifies the width of crop area in pixels
|
|
920
921
|
* (image output) or points (vector output).
|
|
921
|
-
* @param {number
|
|
922
|
+
* @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left
|
|
922
923
|
* corner in pixels (image output) or points (vector output).
|
|
923
|
-
* @param {number
|
|
924
|
+
* @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left
|
|
924
925
|
* corner in pixels (image output) or points (vector output).
|
|
925
|
-
* @param {string
|
|
926
|
+
* @param {string} [options.defaultCmykProfile] - If Poppler is compiled with colour management support, this option
|
|
926
927
|
* sets the DefaultCMYK color space to the ICC profile stored in the display profile file passed.
|
|
927
|
-
* @param {string
|
|
928
|
+
* @param {string} [options.defaultGrayProfile] - If Poppler is compiled with colour management support, this option
|
|
928
929
|
* sets the DefaultGray color space to the ICC profile stored in the display profile file passed.
|
|
929
|
-
* @param {string
|
|
930
|
+
* @param {string} [options.defaultRgbProfile] - If Poppler is compiled with colour management support, this option
|
|
930
931
|
* sets the DefaultRGB color space to the ICC profile stored in the display profile file passed.
|
|
931
|
-
* @param {string
|
|
932
|
+
* @param {string} [options.displayProfile] - If Poppler is compiled with colour management support, this option
|
|
932
933
|
* sets the display profile to the ICC profile stored in the display profile file passed.
|
|
933
|
-
* @param {boolean
|
|
934
|
-
* @param {number
|
|
935
|
-
* @param {('
|
|
934
|
+
* @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages.
|
|
935
|
+
* @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
|
|
936
|
+
* @param {('no'|'yes')} [options.freetype] - Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
|
|
936
937
|
* This defaults to `yes`.
|
|
937
|
-
* @param {boolean
|
|
938
|
-
* @param {boolean
|
|
939
|
-
* @param {boolean
|
|
940
|
-
* @param {boolean
|
|
941
|
-
* @param {number
|
|
942
|
-
* @param {boolean
|
|
943
|
-
* @param {boolean
|
|
944
|
-
* @param {string
|
|
938
|
+
* @param {boolean} [options.forcePageNumber] - Force page number even if there is only one page.
|
|
939
|
+
* @param {boolean} [options.grayscaleFile] - Generate grayscale PGM file (instead of a color PPM file).
|
|
940
|
+
* @param {boolean} [options.hideAnnotations] - Hide annotations.
|
|
941
|
+
* @param {boolean} [options.jpegFile] - Generate JPEG file instead a PPM file.
|
|
942
|
+
* @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
|
|
943
|
+
* @param {boolean} [options.monochromeFile] - Generate monochrome PBM file (instead of a color PPM file).
|
|
944
|
+
* @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages.
|
|
945
|
+
* @param {string} [options.ownerPassword] - Specify the owner password for the PDF file.
|
|
945
946
|
* Providing this will bypass all security restrictions.
|
|
946
|
-
* @param {boolean
|
|
947
|
-
* @param {boolean
|
|
947
|
+
* @param {boolean} [options.pngFile] - Generate PNG file instead a PPM file.
|
|
948
|
+
* @param {boolean} [options.printProgress] - Print progress info as each page is generated.
|
|
948
949
|
* Three space-separated fields are printed to STDERR: the number of the current page, the number
|
|
949
950
|
* of the last page that will be generated, and the path to the file written to.
|
|
950
|
-
* @param {boolean
|
|
951
|
-
* @param {boolean
|
|
952
|
-
* @param {number
|
|
951
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version information.
|
|
952
|
+
* @param {boolean} [options.quiet] - Do not print any messages or errors.
|
|
953
|
+
* @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of
|
|
953
954
|
* image files (or rasterized regions in vector output). The default is 150 PPI.
|
|
954
|
-
* @param {number
|
|
955
|
+
* @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per
|
|
955
956
|
* inch of image files (or rasterized regions in vector output). The default is 150 PPI.
|
|
956
|
-
* @param {number
|
|
957
|
+
* @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of
|
|
957
958
|
* image files (or rasterized regions in vector output). The default is 150 PPI.
|
|
958
|
-
* @param {number
|
|
959
|
+
* @param {number} [options.scalePageTo] - Scales the long side of each page (width for landscape
|
|
959
960
|
* pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will
|
|
960
961
|
* be determined by the aspect ratio of the page.
|
|
961
|
-
* @param {number
|
|
962
|
+
* @param {number} [options.scalePageToXAxis] - Scales each page horizontally to fit in scale-to-x
|
|
962
963
|
* pixels. If scale-to-y is set to -1, the vertical size will determined by the aspect ratio of
|
|
963
964
|
* the page.
|
|
964
|
-
* @param {number
|
|
965
|
+
* @param {number} [options.scalePageToYAxis] - Scales each page vertically to fit in scale-to-y
|
|
965
966
|
* pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio of
|
|
966
967
|
* the page.
|
|
967
|
-
* @param {string
|
|
968
|
-
* @param {boolean
|
|
969
|
-
* @param {('none'|'
|
|
970
|
-
* @param {('
|
|
971
|
-
* @param {boolean
|
|
972
|
-
* @param {string
|
|
968
|
+
* @param {string} [options.separator] - Specify single character separator between name and page number.
|
|
969
|
+
* @param {boolean} [options.singleFile] - Writes only the first page and does not add digits.
|
|
970
|
+
* @param {('none'|'shape'|'solid')} [options.thinLineMode] - Specifies the thin line mode. This defaults to `none`.
|
|
971
|
+
* @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression.
|
|
972
|
+
* @param {boolean} [options.tiffFile] - Generate TIFF file instead a PPM file.
|
|
973
|
+
* @param {string} [options.userPassword] - Specify the user password for the PDF file.
|
|
973
974
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
974
975
|
*/
|
|
975
976
|
async pdfToPpm(file, outputPath, options = {}) {
|
|
@@ -1097,110 +1098,110 @@ class Poppler {
|
|
|
1097
1098
|
/**
|
|
1098
1099
|
* @author Frazer Smith
|
|
1099
1100
|
* @description Converts a PDF file to PostScript (PS).
|
|
1100
|
-
* @param {Buffer|
|
|
1101
|
-
* @param {string
|
|
1101
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1102
|
+
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1102
1103
|
* If `undefined` then will write output to stdout.
|
|
1103
|
-
* @param {object
|
|
1104
|
-
* @param {('
|
|
1105
|
-
* @param {boolean
|
|
1104
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
1105
|
+
* @param {('no'|'yes')} [options.antialias] - Enable anti-aliasing on rasterization, accepts `no` or `yes`.
|
|
1106
|
+
* @param {boolean} [options.binary] - Write binary data in Level 1 PostScript. By default,
|
|
1106
1107
|
* pdftops writes hex-encoded data in Level 1 PostScript. Binary data is non-standard in Level 1
|
|
1107
1108
|
* PostScript but reduces the file size and can be useful when Level 1 PostScript is required
|
|
1108
1109
|
* only for its restricted use of PostScript operators.
|
|
1109
|
-
* @param {string
|
|
1110
|
+
* @param {string} [options.defaultCmykProfile] - If Poppler is compiled with colour management support, this option
|
|
1110
1111
|
* sets the DefaultCMYK color space to the ICC profile stored in the display profile file passed.
|
|
1111
|
-
* @param {string
|
|
1112
|
+
* @param {string} [options.defaultGrayProfile] - If Poppler is compiled with colour management support, this option
|
|
1112
1113
|
* sets the DefaultGray color space to the ICC profile stored in the display profile file passed.
|
|
1113
|
-
* @param {string
|
|
1114
|
+
* @param {string} [options.defaultRgbProfile] - If Poppler is compiled with colour management support, this option
|
|
1114
1115
|
* sets the DefaultRGB color space to the ICC profile stored in the display profile file passed.
|
|
1115
|
-
* @param {boolean
|
|
1116
|
+
* @param {boolean} [options.duplex] - Set the Duplex pagedevice entry in the PostScript file.
|
|
1116
1117
|
* This tells duplex-capable printers to enable duplexing.
|
|
1117
|
-
* @param {boolean
|
|
1118
|
+
* @param {boolean} [options.epsFile] - Generate an EPS file. An EPS file contains a single image,
|
|
1118
1119
|
* so if you use this option with a multi-page PDF file, you must use `options.firstPageToConvert` and
|
|
1119
1120
|
* `options.lastPageToConvert` to specify a single page.
|
|
1120
1121
|
* The page size options (originalPageSizes, paperSize, paperWidth, paperHeight) can not be used
|
|
1121
1122
|
* with this option.
|
|
1122
|
-
* @param {boolean
|
|
1123
|
+
* @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the
|
|
1123
1124
|
* paper. By default, these pages are not scaled.
|
|
1124
|
-
* @param {number
|
|
1125
|
-
* @param {number
|
|
1125
|
+
* @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
|
|
1126
|
+
* @param {number} [options.form] - Generate PostScript form which can be imported by software
|
|
1126
1127
|
* that understands forms.
|
|
1127
1128
|
* A form contains a single page, so if you use this option with a multi-page PDF file,
|
|
1128
1129
|
* you must use `options.firstPageToConvert` and `options.lastPageToConvert` to specify a single page.
|
|
1129
1130
|
* The `options.level1` option cannot be used with `options.form`.
|
|
1130
1131
|
* No more than one of the mode options (`options.epsFile`, `options.form`) may be given.
|
|
1131
|
-
* @param {number
|
|
1132
|
-
* @param {boolean
|
|
1132
|
+
* @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
|
|
1133
|
+
* @param {boolean} [options.level1] - Generate Level 1 PostScript. The resulting PostScript
|
|
1133
1134
|
* files will be significantly larger (if they contain images), but will print on Level 1 printers.
|
|
1134
1135
|
* This also converts all images to black and white.
|
|
1135
|
-
* @param {boolean
|
|
1136
|
+
* @param {boolean} [options.level1Sep] - Generate Level 1 separable PostScript.
|
|
1136
1137
|
* All colors are converted to CMYK. Images are written with separate stream data for the four components.
|
|
1137
|
-
* @param {boolean
|
|
1138
|
+
* @param {boolean} [options.level2] - Generate Level 2 PostScript.
|
|
1138
1139
|
* Level 2 supports color images and image compression. This is the default setting.
|
|
1139
|
-
* @param {boolean
|
|
1140
|
+
* @param {boolean} [options.level2Sep] - Generate Level 2 separable PostScript. All colors are
|
|
1140
1141
|
* converted to CMYK. The PostScript separation convention operators are used to handle custom (spot) colors.
|
|
1141
|
-
* @param {boolean
|
|
1142
|
+
* @param {boolean} [options.level3] - Generate Level 3 PostScript.
|
|
1142
1143
|
* This enables all Level 2 featuresplus CID font embedding.
|
|
1143
|
-
* @param {boolean
|
|
1144
|
+
* @param {boolean} [options.level3Sep] - Generate Level 3 separable PostScript.
|
|
1144
1145
|
* The separation handling is the same as for `options.level2Sep`.
|
|
1145
|
-
* @param {boolean
|
|
1146
|
+
* @param {boolean} [options.noEmbedCIDFonts] - By default, any CID PostScript fonts which are
|
|
1146
1147
|
* embedded in the PDF file are copied into the PostScript file. This option disables that embedding.
|
|
1147
1148
|
* No attempt is made to substitute for non-embedded CID PostScript fonts.
|
|
1148
|
-
* @param {boolean
|
|
1149
|
+
* @param {boolean} [options.noEmbedCIDTrueTypeFonts] - By default, any CID TrueType fonts which are
|
|
1149
1150
|
* embedded in the PDF file are copied into the PostScript file. This option disables that embedding.
|
|
1150
1151
|
* No attempt is made to substitute for non-embedded CID TrueType fonts.
|
|
1151
|
-
* @param {boolean
|
|
1152
|
+
* @param {boolean} [options.noEmbedTrueTypeFonts] - By default, any TrueType fonts which are embedded
|
|
1152
1153
|
* in the PDF file are copied into the PostScript file. This option causes pdfToPs to substitute base fonts instead.
|
|
1153
1154
|
* Embedded fonts make PostScript files larger, but may be necessary for readable output.
|
|
1154
1155
|
* Also, some PostScript interpreters do not have TrueType rasterizers.
|
|
1155
|
-
* @param {boolean
|
|
1156
|
+
* @param {boolean} [options.noEmbedType1Fonts] - By default, any Type 1 fonts which are embedded in the PDF file
|
|
1156
1157
|
* are copied into the PostScript file. This option causes pdfToPs to substitute base fonts instead.
|
|
1157
1158
|
* Embedded fonts make PostScript files larger, but may be necessary for readable output.
|
|
1158
|
-
* @param {boolean
|
|
1159
|
+
* @param {boolean} [options.noCenter] - By default, PDF pages smaller than the paper
|
|
1159
1160
|
* (after any scaling) are centered on the paper. This option causes them to be aligned to
|
|
1160
1161
|
* the lower-left corner of the paper instead.
|
|
1161
|
-
* @param {boolean
|
|
1162
|
+
* @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox
|
|
1162
1163
|
* specified in the PDF file. This option disables cropping.
|
|
1163
|
-
* @param {boolean
|
|
1164
|
+
* @param {boolean} [options.noShrink] - Do not scale PDF pages which are larger than the paper.
|
|
1164
1165
|
* By default, pages larger than the paper are shrunk to fit.
|
|
1165
|
-
* @param {boolean
|
|
1166
|
-
* @param {boolean
|
|
1166
|
+
* @param {boolean} [options.opi] - Generate OPI comments for all images and forms which have OPI information.
|
|
1167
|
+
* @param {boolean} [options.optimizecolorspace] - By default, bitmap images in the PDF pass through to the
|
|
1167
1168
|
* output PostScript in their original color space, which produces predictable results.
|
|
1168
1169
|
* This option converts RGB and CMYK images into Gray images if every pixel of the image has equal components.
|
|
1169
1170
|
* This can fix problems when doing color separations of PDFs that contain embedded black and
|
|
1170
1171
|
* white images encoded as RGB.
|
|
1171
|
-
* @param {boolean
|
|
1172
|
+
* @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match
|
|
1172
1173
|
* the size specified in the PDF file.
|
|
1173
|
-
* @param {boolean
|
|
1174
|
-
* @param {string
|
|
1175
|
-
* @param {number
|
|
1176
|
-
* @param {('
|
|
1177
|
-
* or `
|
|
1174
|
+
* @param {boolean} [options.overprint] - Enable overprinting.
|
|
1175
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
1176
|
+
* @param {number} [options.paperHeight] - Set the paper height, in points.
|
|
1177
|
+
* @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - Set the paper size to one of `A3`, `A4`,
|
|
1178
|
+
* `legal`, or `letter`. This can also be set to `match`, which will set the paper size
|
|
1178
1179
|
* of each page to match the size specified in the PDF file. If none of the paperSize,
|
|
1179
1180
|
* paperWidth, or paperHeight options are specified the default is to match the paper size.
|
|
1180
|
-
* @param {number
|
|
1181
|
-
* @param {boolean
|
|
1181
|
+
* @param {number} [options.paperWidth] - Set the paper width, in points.
|
|
1182
|
+
* @param {boolean} [options.passfonts] - By default, references to non-embedded 8-bit fonts
|
|
1182
1183
|
* in the PDF file are substituted with the closest `Helvetica`, `Times-Roman`, or `Courier` font.
|
|
1183
1184
|
* This option passes references to non-embedded fonts through to the PostScript file.
|
|
1184
|
-
* @param {boolean
|
|
1185
|
-
* @param {boolean
|
|
1186
|
-
* @param {('CMYK8'|'MONO8'|'RGB8')
|
|
1185
|
+
* @param {boolean} [options.preload] - Preload images and forms.
|
|
1186
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version information.
|
|
1187
|
+
* @param {('CMYK8'|'MONO8'|'RGB8')} [options.processColorFormat] - Sets the process color format as it is used
|
|
1187
1188
|
* during rasterization and transparency reduction.
|
|
1188
1189
|
*
|
|
1189
1190
|
* The default depends on the other settings: For `options.level1` the default is MONO8; for `options.level1Sep`,
|
|
1190
1191
|
* `options.level2Sep`, `options.level3Sep`, or `options.overprint` the default is CMYK8; in all other
|
|
1191
1192
|
* cases RGB8 is the default.
|
|
1192
1193
|
* If `option.processColorProfile` is set then `options.processColorFormat` is inferred from the specified ICC profile.
|
|
1193
|
-
* @param {string
|
|
1194
|
+
* @param {string} [options.processColorProfile] - Sets the ICC profile that is assumed during
|
|
1194
1195
|
* rasterization and transparency reduction.
|
|
1195
|
-
* @param {boolean
|
|
1196
|
-
* @param {('always'|'never'|'whenneeded')
|
|
1196
|
+
* @param {boolean} [options.quiet] - Do not print any messages or errors.
|
|
1197
|
+
* @param {('always'|'never'|'whenneeded')} [options.rasterize] - By default, pdfToPs rasterizes pages as needed,
|
|
1197
1198
|
* for example, if they contain transparencies. To force rasterization, set `rasterize` to `always`.
|
|
1198
1199
|
* Use this to eliminate fonts.
|
|
1199
1200
|
* To prevent rasterization, set `rasterize` to `never`.
|
|
1200
1201
|
* This may produce files that display incorrectly.
|
|
1201
|
-
* @param {number
|
|
1202
|
+
* @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per
|
|
1202
1203
|
* inch of image files (or rasterized regions in vector output). The default is 300 PPI.
|
|
1203
|
-
* @param {string
|
|
1204
|
+
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
1204
1205
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1205
1206
|
*/
|
|
1206
1207
|
async pdfToPs(file, outputFile, options = {}) {
|
|
@@ -1338,49 +1339,49 @@ class Poppler {
|
|
|
1338
1339
|
/**
|
|
1339
1340
|
* @author Frazer Smith
|
|
1340
1341
|
* @description Converts a PDF file to TXT.
|
|
1341
|
-
* @param {Buffer|
|
|
1342
|
-
* @param {string
|
|
1342
|
+
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1343
|
+
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1343
1344
|
* If `undefined` then will write output to stdout.
|
|
1344
|
-
* @param {object
|
|
1345
|
-
* @param {boolean
|
|
1345
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
1346
|
+
* @param {boolean} [options.boundingBoxXhtml] - Generate an XHTML file containing bounding
|
|
1346
1347
|
* box information for each word in the file.
|
|
1347
|
-
* @param {boolean
|
|
1348
|
+
* @param {boolean} [options.boundingBoxXhtmlLayout] - Generate an XHTML file containing
|
|
1348
1349
|
* bounding box information for each block, line, and word in the file.
|
|
1349
|
-
* @param {boolean
|
|
1350
|
+
* @param {boolean} [options.cropBox] - Use the crop box rather than the media box with
|
|
1350
1351
|
* `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout`
|
|
1351
|
-
* @param {number
|
|
1352
|
+
* @param {number} [options.cropHeight] - Specifies the height of crop area in pixels
|
|
1352
1353
|
* (image output) or points (vector output).
|
|
1353
|
-
* @param {number
|
|
1354
|
+
* @param {number} [options.cropWidth] - Specifies the width of crop area in pixels
|
|
1354
1355
|
* (image output) or points (vector output).
|
|
1355
|
-
* @param {number
|
|
1356
|
+
* @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left
|
|
1356
1357
|
* corner in pixels (image output) or points (vector output).
|
|
1357
|
-
* @param {number
|
|
1358
|
+
* @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left
|
|
1358
1359
|
* corner in pixels (image output) or points (vector output).
|
|
1359
|
-
* @param {('
|
|
1360
|
-
* text output:
|
|
1361
|
-
* @param {number
|
|
1362
|
-
* @param {number
|
|
1360
|
+
* @param {('dos'|'mac'|'unix')} [options.eolConvention] - Sets the end-of-line convention to use for
|
|
1361
|
+
* text output: dos; mac; unix.
|
|
1362
|
+
* @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
|
|
1363
|
+
* @param {number} [options.fixedWidthLayout] - Assume fixed-pitch (or tabular) text, with the
|
|
1363
1364
|
* specified character width (in points). This forces physical layout mode.
|
|
1364
|
-
* @param {boolean
|
|
1365
|
+
* @param {boolean} [options.generateHtmlMetaFile] - Generate simple HTML file, including the
|
|
1365
1366
|
* meta information. This simply wraps the text in `<pre>` and `</pre>` and prepends the meta headers.
|
|
1366
|
-
* @param {boolean
|
|
1367
|
+
* @param {boolean} [options.generateTsvFile] - Generate a TSV file containing the bounding box
|
|
1367
1368
|
* information for each block, line, and word in the file.
|
|
1368
|
-
* @param {number
|
|
1369
|
-
* @param {boolean
|
|
1370
|
-
* @param {boolean
|
|
1369
|
+
* @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
|
|
1370
|
+
* @param {boolean} [options.listEncodingOptions] - List the available encodings.
|
|
1371
|
+
* @param {boolean} [options.maintainLayout] - Maintain (as best as possible) the original physical
|
|
1371
1372
|
* layout of the text. The default is to undo physical layout (columns, hyphenation, etc.) and
|
|
1372
1373
|
* output the text in reading order.
|
|
1373
|
-
* @param {boolean
|
|
1374
|
-
* @param {boolean
|
|
1374
|
+
* @param {boolean} [options.noDiagonalText] - Discard diagonal text.
|
|
1375
|
+
* @param {boolean} [options.noPageBreaks] - Do not insert page breaks (form feed characters)
|
|
1375
1376
|
* between pages.
|
|
1376
|
-
* @param {string
|
|
1377
|
+
* @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
|
|
1377
1378
|
* This defaults to `UTF-8`.
|
|
1378
|
-
* @param {string
|
|
1379
|
-
* @param {boolean
|
|
1380
|
-
* @param {boolean
|
|
1381
|
-
* @param {boolean
|
|
1379
|
+
* @param {string} [options.ownerPassword] - Owner password (for encrypted files).
|
|
1380
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version information.
|
|
1381
|
+
* @param {boolean} [options.quiet] - Do not print any messages or errors.
|
|
1382
|
+
* @param {boolean} [options.rawLayout] - Keep the text in content stream order. This is a
|
|
1382
1383
|
* hack which often undoes column formatting, etc. Use of raw mode is no longer recommended.
|
|
1383
|
-
* @param {string
|
|
1384
|
+
* @param {string} [options.userPassword] - User password (for encrypted files).
|
|
1384
1385
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1385
1386
|
*/
|
|
1386
1387
|
async pdfToText(file, outputFile, options = {}) {
|
|
@@ -1488,11 +1489,11 @@ class Poppler {
|
|
|
1488
1489
|
* @author Frazer Smith
|
|
1489
1490
|
* @description Merges several PDF files in order of their occurrence in the files array to
|
|
1490
1491
|
* one PDF result file.
|
|
1491
|
-
* @param {
|
|
1492
|
+
* @param {string[]} files - Filepaths of the PDF files to merge.
|
|
1492
1493
|
* An entire directory of PDF files can be merged like so: `path/to/directory/*.pdf`.
|
|
1493
1494
|
* @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
|
|
1494
|
-
* @param {object
|
|
1495
|
-
* @param {boolean
|
|
1495
|
+
* @param {object} [options] - Object containing options to pass to binary.
|
|
1496
|
+
* @param {boolean} [options.printVersionInfo] - Print copyright and version information.
|
|
1496
1497
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1497
1498
|
*/
|
|
1498
1499
|
async pdfUnite(files, outputFile, options = {}) {
|