node-poppler 6.2.6 → 7.0.0

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/types/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  export default Poppler;
2
2
  export class Poppler {
3
- /**
4
- * @param {string=} binPath - Path of poppler-utils binaries.
5
- */
6
- constructor(binPath?: string | undefined);
3
+ /** @param {string} [binPath] - Path of poppler-utils binaries. */
4
+ constructor(binPath?: string);
7
5
  popplerPath: string;
8
6
  /**
9
7
  * @author Frazer Smith
@@ -11,129 +9,185 @@ export class Poppler {
11
9
  * @param {string} file - Filepath of the PDF file to read.
12
10
  * @param {string} fileToAttach - Filepath of the attachment to be embedded into the PDF file.
13
11
  * @param {string} outputFile - Filepath of the file to output the results to.
14
- * @param {object=} options - Object containing options to pass to binary.
15
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
16
- * @param {boolean=} options.replace - Replace embedded file with same name (if it exists).
12
+ * @param {object} [options] - Object containing options to pass to binary.
13
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
14
+ * @param {boolean} [options.replace] - Replace embedded file with same name (if it exists).
17
15
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
18
16
  */
19
17
  pdfAttach(
20
18
  file: string,
21
19
  fileToAttach: string,
22
20
  outputFile: string,
23
- options?: object | undefined
21
+ options?: {
22
+ printVersionInfo?: boolean;
23
+ replace?: boolean;
24
+ }
24
25
  ): Promise<string>;
25
26
  /**
26
27
  * @author Frazer Smith
27
28
  * @description Lists or extracts embedded files (attachments) from a PDF file.
28
29
  * @param {string} file - Filepath of the PDF file to read.
29
- * @param {object=} options - Object containing options to pass to binary.
30
- * @param {boolean=} options.listEmbedded - List all of the embedded files in the PDF file.
30
+ * @param {object} [options] - Object containing options to pass to binary.
31
+ * @param {boolean} [options.listEmbedded] - List all of the embedded files in the PDF file.
31
32
  * File names are converted to the text encoding specified by `options.outputEncoding`.
32
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
33
- * @param {string=} options.outputEncoding - Sets the encoding to use for text output.
33
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
34
+ * @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
34
35
  * This defaults to `UTF-8`.
35
- * @param {string=} options.outputPath - Set the file name used when saving an embedded file with
36
+ * @param {string} [options.outputPath] - Set the file name used when saving an embedded file with
36
37
  * the save option enabled, or the directory if `options.saveall` is used.
37
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
38
- * @param {boolean=} options.saveAllFiles - Save all of the embedded files. This uses the file
38
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
39
+ * @param {boolean} [options.saveAllFiles] - Save all of the embedded files. This uses the file
39
40
  * names associated with the embedded files (as printed by `options.listEmbedded`).
40
41
  * By default, the files are saved in the current directory; this can be changed
41
42
  * with `options.outputPath`.
42
- * @param {string=} options.saveFile - Save the specified embedded file.
43
+ * @param {string} [options.saveFile] - Save the specified embedded file.
43
44
  * By default, this uses the file name associated with the embedded file (as printed by
44
45
  * `options.listEmbedded`); the file name can be changed with `options.outputPath`.
45
- * @param {number=} options.saveSpecificFile - Save the specified embedded file.
46
+ * @param {number} [options.saveSpecificFile] - Save the specified embedded file.
46
47
  * By default, this uses the file name associated with the embedded file (as printed by
47
48
  * `options.listEmbedded`); the file name can be changed with `options.outputPath`.
48
- * @param {string=} options.userPassword - User password (for encrypted files).
49
+ * @param {string} [options.userPassword] - User password (for encrypted files).
49
50
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
50
51
  */
51
- pdfDetach(file: string, options?: object | undefined): Promise<string>;
52
+ pdfDetach(
53
+ file: string,
54
+ options?: {
55
+ listEmbedded?: boolean;
56
+ ownerPassword?: string;
57
+ outputEncoding?: string;
58
+ outputPath?: string;
59
+ printVersionInfo?: boolean;
60
+ saveAllFiles?: boolean;
61
+ saveFile?: string;
62
+ saveSpecificFile?: number;
63
+ userPassword?: string;
64
+ }
65
+ ): Promise<string>;
52
66
  /**
53
67
  * @author Frazer Smith
54
68
  * @description Lists the fonts used in a PDF file along with various information for each font.
55
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
56
- * @param {object=} options - Object containing options to pass to binary.
57
- * @param {number=} options.firstPageToExamine - Specifies the first page to examine.
58
- * @param {number=} options.lastPageToExamine - Specifies the last page to examine.
59
- * @param {boolean=} options.listSubstitutes - List the substitute fonts that poppler
69
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
70
+ * @param {object} [options] - Object containing options to pass to binary.
71
+ * @param {number} [options.firstPageToExamine] - Specifies the first page to examine.
72
+ * @param {number} [options.lastPageToExamine] - Specifies the last page to examine.
73
+ * @param {boolean} [options.listSubstitutes] - List the substitute fonts that poppler
60
74
  * will use for non-embedded fonts.
61
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
62
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
63
- * @param {string=} options.userPassword - User password (for encrypted files). *
75
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
76
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
77
+ * @param {string} [options.userPassword] - User password (for encrypted files). *
64
78
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
65
79
  */
66
80
  pdfFonts(
67
81
  file: Buffer | string,
68
- options?: object | undefined
82
+ options?: {
83
+ firstPageToExamine?: number;
84
+ lastPageToExamine?: number;
85
+ listSubstitutes?: boolean;
86
+ ownerPassword?: string;
87
+ printVersionInfo?: boolean;
88
+ userPassword?: string;
89
+ }
69
90
  ): Promise<string>;
70
91
  /**
71
92
  * @author Frazer Smith
72
93
  * @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files.
73
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
74
- * @param {string=} outputPrefix - Filename prefix of output files.
75
- * @param {object=} options - Object containing options to pass to binary.
76
- * @param {boolean=} options.allFiles - Write JPEG, JPEG2000, JBIG2, and CCITT images in their native format.
94
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
95
+ * @param {string} [outputPrefix] - Filename prefix of output files.
96
+ * @param {object} [options] - Object containing options to pass to binary.
97
+ * @param {boolean} [options.allFiles] - Write JPEG, JPEG2000, JBIG2, and CCITT images in their native format.
77
98
  * CMYK files are written as TIFF files. All other images are written as PNG files.
78
- * @param {boolean=} options.ccittFile - Generate CCITT images as CCITT files.
79
- * @param {number=} options.firstPageToConvert - Specifies the first page to convert.
80
- * @param {number=} options.lastPageToConvert - Specifies the last page to convert.
81
- * @param {boolean=} options.list - Instead of writing the images, list the
99
+ * @param {boolean} [options.ccittFile] - Generate CCITT images as CCITT files.
100
+ * @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
101
+ * @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
102
+ * @param {boolean} [options.list] - Instead of writing the images, list the
82
103
  * images along with various information for each image.
83
104
  * NOTE: Do not specify the outputPrefix with this option.
84
- * @param {boolean=} options.jbig2File - Generate JBIG2 images as JBIG2 files.
85
- * @param {boolean=} options.jpeg2000File - Generate JPEG2000 images at JP2 files.
86
- * @param {boolean=} options.jpegFile - Generate JPEG images as JPEG files.
87
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
88
- * @param {boolean=} options.pngFile - Change the default output format to PNG.
89
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
90
- * @param {boolean=} options.tiffFile - Change the default output format to TIFF.
91
- * @param {string=} options.userPassword - Specify the user password for the PDF file.
105
+ * @param {boolean} [options.jbig2File] - Generate JBIG2 images as JBIG2 files.
106
+ * @param {boolean} [options.jpeg2000File] - Generate JPEG2000 images at JP2 files.
107
+ * @param {boolean} [options.jpegFile] - Generate JPEG images as JPEG files.
108
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
109
+ * @param {boolean} [options.pngFile] - Change the default output format to PNG.
110
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
111
+ * @param {boolean} [options.tiffFile] - Change the default output format to TIFF.
112
+ * @param {string} [options.userPassword] - Specify the user password for the PDF file.
92
113
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
93
114
  */
94
115
  pdfImages(
95
116
  file: Buffer | string,
96
- outputPrefix?: string | undefined,
97
- options?: object | undefined
117
+ outputPrefix?: string,
118
+ options?: {
119
+ allFiles?: boolean;
120
+ ccittFile?: boolean;
121
+ firstPageToConvert?: number;
122
+ lastPageToConvert?: number;
123
+ list?: boolean;
124
+ jbig2File?: boolean;
125
+ jpeg2000File?: boolean;
126
+ jpegFile?: boolean;
127
+ ownerPassword?: string;
128
+ pngFile?: boolean;
129
+ printVersionInfo?: boolean;
130
+ tiffFile?: boolean;
131
+ userPassword?: string;
132
+ }
98
133
  ): Promise<string>;
99
134
  /**
100
135
  * @author Frazer Smith
101
136
  * @description Prints the contents of the `Info` dictionary from a PDF file.
102
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
103
- * @param {object=} options - Object containing options to pass to binary.
104
- * @param {number=} options.firstPageToConvert - First page to print.
105
- * @param {number=} options.lastPageToConvert - Last page to print.
106
- * @param {boolean=} options.listEncodingOptions - List the available encodings.
107
- * @param {string=} options.outputEncoding - Sets the encoding to use for text output.
137
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
138
+ * @param {object} [options] - Object containing options to pass to binary.
139
+ * @param {number} [options.firstPageToConvert] - First page to print.
140
+ * @param {number} [options.lastPageToConvert] - Last page to print.
141
+ * @param {boolean} [options.listEncodingOptions] - List the available encodings.
142
+ * @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
108
143
  * This defaults to `UTF-8`.
109
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
110
- * @param {boolean=} options.printAsJson - Print result as a JSON object.
111
- * @param {boolean=} options.printBoundingBoxes - Prints the page box bounding boxes:
144
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
145
+ * @param {boolean} [options.printAsJson] - Print result as a JSON object.
146
+ * @param {boolean} [options.printBoundingBoxes] - Prints the page box bounding boxes:
112
147
  * MediaBox, CropBox, BleedBox, TrimBox, and ArtBox.
113
- * @param {boolean=} options.printDocStruct - Prints the logical document structure
148
+ * @param {boolean} [options.printDocStruct] - Prints the logical document structure
114
149
  * of a Tagged-PDF file.
115
- * @param {boolean=} options.printDocStructText - Print the textual content along with the
150
+ * @param {boolean} [options.printDocStructText] - Print the textual content along with the
116
151
  * document structure of a Tagged-PDF file. Note that extracting text this way might be slow
117
152
  *
118
153
  * for big PDF files.
119
- * @param {boolean=} options.printIsoDates - Prints dates in ISO-8601 format (including the time zone).
120
- * @param {boolean=} options.printJS - Prints all JavaScript in the PDF file.
121
- * @param {boolean=} options.printMetadata - Prints document-level metadata. (This is the `Metadata`
154
+ * @param {boolean} [options.printIsoDates] - Prints dates in ISO-8601 format (including the time zone).
155
+ * @param {boolean} [options.printJS] - Prints all JavaScript in the PDF file.
156
+ * @param {boolean} [options.printMetadata] - Prints document-level metadata. (This is the `Metadata`
122
157
  * stream from the PDF file's Catalog object).
123
- * @param {boolean=} options.printNamedDests - Print a list of all named destinations. If a page range
158
+ * @param {boolean} [options.printNamedDests] - Print a list of all named destinations. If a page range
124
159
  * is specified using the `options.firstPageToConvert` and `options.lastPageToConvert` options, only destinations
125
160
  * in the page range are listed.
126
- * @param {boolean=} options.printRawDates - Prints the raw (undecoded) date strings, directly from the PDF file.
127
- * @param {boolean=} options.printUrls - Print all URLs in the PDF; only URLs referenced by PDF objects
161
+ * @param {boolean} [options.printRawDates] - Prints the raw (undecoded) date strings, directly from the PDF file.
162
+ * @param {boolean} [options.printUrls] - Print all URLs in the PDF; only URLs referenced by PDF objects
128
163
  * such as Link Annotations are listed, not URL strings in the text content.
129
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
130
- * @param {string=} options.userPassword - User password (for encrypted files).
131
- * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
164
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
165
+ * @param {string} [options.userPassword] - User password (for encrypted files).
166
+ * @returns {Promise<object|string>} A promise that resolves with a stdout string or JSON object if
167
+ * `options.printAsJson` is `true`, or rejects with an `Error` object.
132
168
  */
133
169
  pdfInfo(
134
170
  file: Buffer | string,
135
- options?: object | undefined
136
- ): Promise<string>;
171
+ options?: {
172
+ firstPageToConvert?: number;
173
+ lastPageToConvert?: number;
174
+ listEncodingOptions?: boolean;
175
+ outputEncoding?: string;
176
+ ownerPassword?: string;
177
+ printAsJson?: boolean;
178
+ printBoundingBoxes?: boolean;
179
+ printDocStruct?: boolean;
180
+ printDocStructText?: boolean;
181
+ printIsoDates?: boolean;
182
+ printJS?: boolean;
183
+ printMetadata?: boolean;
184
+ printNamedDests?: boolean;
185
+ printRawDates?: boolean;
186
+ printUrls?: boolean;
187
+ printVersionInfo?: boolean;
188
+ userPassword?: string;
189
+ }
190
+ ): Promise<object | string>;
137
191
  /**
138
192
  * @author Frazer Smith
139
193
  * @description Extracts single pages from a PDF file,
@@ -143,61 +197,65 @@ export class Poppler {
143
197
  * @param {string} outputPattern - Should contain %d (or any variant respecting printf format),
144
198
  * since %d is replaced by the page number.
145
199
  * As an example, `sample-%d.pdf` will produce `sample-1.pdf` for a single page document.
146
- * @param {object=} options - Object containing options to pass to binary.
147
- * @param {number=} options.firstPageToExtract - Specifies the first page to extract.
200
+ * @param {object} [options] - Object containing options to pass to binary.
201
+ * @param {number} [options.firstPageToExtract] - Specifies the first page to extract.
148
202
  * This defaults to page 1.
149
- * @param {number=} options.lastPageToExtract - Specifies the last page to extract.
203
+ * @param {number} [options.lastPageToExtract] - Specifies the last page to extract.
150
204
  * This defaults to the last page of the PDF file.
151
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
205
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
152
206
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
153
207
  */
154
208
  pdfSeparate(
155
209
  file: string,
156
210
  outputPattern: string,
157
- options?: object | undefined
211
+ options?: {
212
+ firstPageToExtract?: number;
213
+ lastPageToExtract?: number;
214
+ printVersionInfo?: boolean;
215
+ }
158
216
  ): Promise<string>;
159
217
  /**
160
218
  * @author Frazer Smith
161
219
  * @description Converts a PDF file to EPS/JPEG/PDF/PNG/PS/SVG/TIFF.
162
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
163
- * @param {string=} outputFile - Filepath of the file to output the results to.
220
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
221
+ * @param {string} [outputFile] - Filepath of the file to output the results to.
164
222
  *
165
223
  * If `undefined` then will write output to stdout. Using stdout is not valid with image formats
166
224
  * (jpeg, png, and tiff) unless `options.singleFile` is set to `true`.
167
225
  * Encoding is set to `binary` if used with `options.singleFile` or `options.pdfFile`.
168
226
  *
169
227
  * If not set then the output filename will be derived from the PDF file name.
170
- * @param {object=} options - Object containing options to pass to binary.
171
- * @param {('default'|'none'|'gray'|'subpixel'|'fast'|'good'|'best')=} options.antialias - Set the cairo
228
+ * @param {object} [options] - Object containing options to pass to binary.
229
+ * @param {('best'|'default'|'fast'|'good'|'gray'|'none'|'subpixel')} [options.antialias] - Set the cairo
172
230
  * antialias option used for text and drawing in image files (or rasterized regions in vector output).
173
- * @param {boolean=} options.cropBox - Uses the crop box rather than media box when
231
+ * @param {boolean} [options.cropBox] - Uses the crop box rather than media box when
174
232
  * generating the files (PNG/JPEG/TIFF only).
175
- * @param {number=} options.cropHeight - Specifies the height of crop area in pixels
233
+ * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels
176
234
  * (image output) or points (vector output).
177
- * @param {number=} options.cropSize - Specifies the size of crop square in pixels
235
+ * @param {number} [options.cropSize] - Specifies the size of crop square in pixels
178
236
  * (image output) or points (vector output).
179
- * @param {number=} options.cropWidth - Specifies the width of crop area in pixels
237
+ * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels
180
238
  * (image output) or points (vector output).
181
- * @param {number=} options.cropXAxis - Specifies the x-coordinate of the crop area top left
239
+ * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left
182
240
  * corner in pixels (image output) or points (vector output).
183
- * @param {number=} options.cropYAxis - Specifies the y-coordinate of the crop area top left
241
+ * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left
184
242
  * corner in pixels (image output) or points (vector output).
185
- * @param {boolean=} options.duplex - Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC
243
+ * @param {boolean} [options.duplex] - Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC
186
244
  * comment to the PostScript file (PS only). This tells the print manager to enable duplexing.
187
- * @param {boolean=} options.epsFile - Generate an EPS file. An EPS file contains a single image,
245
+ * @param {boolean} [options.epsFile] - Generate an EPS file. An EPS file contains a single image,
188
246
  * so if you use this option with a multi-page PDF file, you must use `options.firstPageToConvert` and
189
247
  * `options.lastPageToConvert` to specify a single page.
190
248
  * The page size options (originalPageSizes, paperSize, paperWidth, paperHeight) can not be used
191
249
  * with this option.
192
- * @param {boolean=} options.evenPagesOnly - Generates only the even numbered pages.
193
- * @param {boolean=} options.fillPage - Expand PDF pages smaller than the paper to fill the
250
+ * @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages.
251
+ * @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the
194
252
  * paper (PS,PDF,SVG only). By default, these pages are not scaled.
195
- * @param {number=} options.firstPageToConvert - Specifies the first page to convert.
196
- * @param {boolean=} options.grayscaleFile - Generate grayscale file (PNG, JPEG, and TIFF only).
197
- * @param {string=} options.iccFile - Use the specified ICC file as the output profile
253
+ * @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
254
+ * @param {boolean} [options.grayscaleFile] - Generate grayscale file (PNG, JPEG, and TIFF only).
255
+ * @param {string} [options.iccFile] - Use the specified ICC file as the output profile
198
256
  * (PNG only). The profile will be embedded in the PNG file.
199
- * @param {boolean=} options.jpegFile - Generate JPEG file(s).
200
- * @param {string=} options.jpegOptions - When used with `options.jpegFile`, this option can
257
+ * @param {boolean} [options.jpegFile] - Generate JPEG file(s).
258
+ * @param {string} [options.jpegOptions] - When used with `options.jpegFile`, this option can
201
259
  * be used to control the JPEG compression parameters. It takes a string of the form
202
260
  * `"<opt>=<val>[,<opt>=<val>]"`. Currently available options are:
203
261
  * - `quality` Selects the JPEG quality value. The value must be an integer between 0 and 100.
@@ -208,369 +266,555 @@ export class Poppler {
208
266
  * with "y" performing optimization, otherwise the default Huffman tables are used.
209
267
  *
210
268
  * Example: `"quality=95,optimize=y"`.
211
- * @param {number=} options.lastPageToConvert - Specifies the last page to convert.
212
- * @param {boolean=} options.monochromeFile - Generate monochrome file (PNG and TIFF only).
213
- * @param {boolean=} options.noCenter - By default, PDF pages smaller than the paper
269
+ * @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
270
+ * @param {boolean} [options.monochromeFile] - Generate monochrome file (PNG and TIFF only).
271
+ * @param {boolean} [options.noCenter] - By default, PDF pages smaller than the paper
214
272
  * (after any scaling) are centered on the paper. This option causes them to be aligned to
215
273
  * the lower-left corner of the paper instead (PS,PDF,SVG only).
216
- * @param {boolean=} options.noCrop - By default, printing output is cropped to the CropBox
274
+ * @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox
217
275
  * specified in the PDF file. This option disables cropping (PS, PDF, SVG only).
218
- * @param {boolean=} options.noShrink - Do not scale PDF pages which are larger than the paper
276
+ * @param {boolean} [options.noShrink] - Do not scale PDF pages which are larger than the paper
219
277
  * (PS,PDF,SVG only). By default, pages larger than the paper are shrunk to fit.
220
- * @param {boolean=} options.oddPagesOnly - Generates only the odd numbered pages.
221
- * @param {boolean=} options.originalPageSizes - Set the paper size of each page to match
278
+ * @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages.
279
+ * @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match
222
280
  * the size specified in the PDF file.
223
- * @param {string=} options.ownerPassword - Specify the owner password for the PDF file.
281
+ * @param {string} [options.ownerPassword] - Specify the owner password for the PDF file.
224
282
  * Providing this will bypass all security restrictions.
225
- * @param {number=} options.paperHeight - Set the paper height, in points (PS, PDF, SVG only).
226
- * @param {('letter'|'legal'|'A4'|'A3'|'match')=} options.paperSize - Set the paper size to one of `letter`, `legal`, `A4`,
227
- * or `A3` (PS,PDF,SVG only). This can also be set to `match`, which will set the paper size
283
+ * @param {number} [options.paperHeight] - Set the paper height, in points (PS, PDF, SVG only).
284
+ * @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - Set the paper size to one of `A3`, `A4`,
285
+ * `legal`, or `letter` (PS,PDF,SVG only). This can also be set to `match`, which will set the paper size
228
286
  * of each page to match the size specified in the PDF file. If none of the paperSize,
229
287
  * paperWidth, or paperHeight options are specified the default is to match the paper size.
230
- * @param {number=} options.paperWidth - Set the paper width, in points (PS,PDF,SVG only).
231
- * @param {boolean=} options.pdfFile - Generate PDF file.
232
- * @param {boolean=} options.pngFile - Generate PNG file(s).
233
- * @param {boolean=} options.printVersionInfo - Print copyright and version information.
234
- * @param {boolean=} options.psFile - Generate PS file.
235
- * @param {boolean=} options.psLevel2 - Generate Level 2 PostScript (PS only).
236
- * @param {boolean=} options.psLevel3 - Generate Level 3 PostScript (PS only). This enables all
288
+ * @param {number} [options.paperWidth] - Set the paper width, in points (PS,PDF,SVG only).
289
+ * @param {boolean} [options.pdfFile] - Generate PDF file.
290
+ * @param {boolean} [options.pngFile] - Generate PNG file(s).
291
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version information.
292
+ * @param {boolean} [options.psFile] - Generate PS file.
293
+ * @param {boolean} [options.psLevel2] - Generate Level 2 PostScript (PS only).
294
+ * @param {boolean} [options.psLevel3] - Generate Level 3 PostScript (PS only). This enables all
237
295
  * Level 2 features plus shading patterns and masked images. This is the default setting.
238
- * @param {boolean=} options.quiet - Do not print any messages or errors.
239
- * @param {number=} options.resolutionXAxis - Specifies the X resolution, in pixels per inch of
296
+ * @param {boolean} [options.quiet] - Do not print any messages or errors.
297
+ * @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of
240
298
  * image files (or rasterized regions in vector output). The default is 150 PPI.
241
- * @param {number=} options.resolutionXYAxis - Specifies the X and Y resolution, in pixels per
299
+ * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per
242
300
  * inch of image files (or rasterized regions in vector output). The default is 150 PPI.
243
- * @param {number=} options.resolutionYAxis - Specifies the Y resolution, in pixels per inch of
301
+ * @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of
244
302
  * image files (or rasterized regions in vector output). The default is 150 PPI.
245
- * @param {number=} options.scalePageTo - Scales the long side of each page (width for landscape
303
+ * @param {number} [options.scalePageTo] - Scales the long side of each page (width for landscape
246
304
  * pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will
247
305
  * be determined by the aspect ratio of the page (PNG/JPEG/TIFF only).
248
- * @param {number=} options.scalePageToXAxis - Scales each page horizontally to fit in scale-to-x
306
+ * @param {number} [options.scalePageToXAxis] - Scales each page horizontally to fit in scale-to-x
249
307
  * pixels. If scale-to-y is set to -1, the vertical size will determined by the aspect ratio of
250
308
  * the page (PNG/JPEG/TIFF only).
251
- * @param {number=} options.scalePageToYAxis - Scales each page vertically to fit in scale-to-y
309
+ * @param {number} [options.scalePageToYAxis] - Scales each page vertically to fit in scale-to-y
252
310
  * pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio of
253
311
  * the page (PNG/JPEG/TIFF only).
254
- * @param {boolean=} options.singleFile - Writes only the first page and does not add digits.
312
+ * @param {boolean} [options.singleFile] - Writes only the first page and does not add digits.
255
313
  * Can only be used with `options.jpegFile`, `options.pngFile`, and `options.tiffFile`.
256
- * @param {boolean=} options.svgFile - Generate SVG (Scalable Vector Graphics) file.
257
- * @param {('none'|'packbits'|'jpeg'|'lzw'|'deflate')=} options.tiffCompression - Set TIFF compression.
258
- * @param {boolean=} options.tiffFile - Generate TIFF file(s).
259
- * @param {boolean=} options.transparentPageColor - Use a transparent page color
314
+ * @param {boolean} [options.svgFile] - Generate SVG (Scalable Vector Graphics) file.
315
+ * @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression.
316
+ * @param {boolean} [options.tiffFile] - Generate TIFF file(s).
317
+ * @param {boolean} [options.transparentPageColor] - Use a transparent page color
260
318
  * instead of white (PNG and TIFF only).
261
- * @param {string=} options.userPassword - Specify the user password for the PDF file.
319
+ * @param {string} [options.userPassword] - Specify the user password for the PDF file.
262
320
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
263
321
  */
264
322
  pdfToCairo(
265
323
  file: Buffer | string,
266
- outputFile?: string | undefined,
267
- options?: object | undefined
324
+ outputFile?: string,
325
+ options?: {
326
+ antialias?:
327
+ | "best"
328
+ | "default"
329
+ | "fast"
330
+ | "good"
331
+ | "gray"
332
+ | "none"
333
+ | "subpixel";
334
+ cropBox?: boolean;
335
+ cropHeight?: number;
336
+ cropSize?: number;
337
+ cropWidth?: number;
338
+ cropXAxis?: number;
339
+ cropYAxis?: number;
340
+ duplex?: boolean;
341
+ epsFile?: boolean;
342
+ evenPagesOnly?: boolean;
343
+ fillPage?: boolean;
344
+ firstPageToConvert?: number;
345
+ grayscaleFile?: boolean;
346
+ iccFile?: string;
347
+ jpegFile?: boolean;
348
+ jpegOptions?: string;
349
+ lastPageToConvert?: number;
350
+ monochromeFile?: boolean;
351
+ noCenter?: boolean;
352
+ noCrop?: boolean;
353
+ noShrink?: boolean;
354
+ oddPagesOnly?: boolean;
355
+ originalPageSizes?: boolean;
356
+ ownerPassword?: string;
357
+ paperHeight?: number;
358
+ paperSize?: "A3" | "A4" | "legal" | "letter" | "match";
359
+ paperWidth?: number;
360
+ pdfFile?: boolean;
361
+ pngFile?: boolean;
362
+ printVersionInfo?: boolean;
363
+ psFile?: boolean;
364
+ psLevel2?: boolean;
365
+ psLevel3?: boolean;
366
+ quiet?: boolean;
367
+ resolutionXAxis?: number;
368
+ resolutionXYAxis?: number;
369
+ resolutionYAxis?: number;
370
+ scalePageTo?: number;
371
+ scalePageToXAxis?: number;
372
+ scalePageToYAxis?: number;
373
+ singleFile?: boolean;
374
+ svgFile?: boolean;
375
+ tiffCompression?: "deflate" | "jpeg" | "lzw" | "none" | "packbits";
376
+ tiffFile?: boolean;
377
+ transparentPageColor?: boolean;
378
+ userPassword?: string;
379
+ }
268
380
  ): Promise<string>;
269
381
  /**
270
382
  * @author Frazer Smith
271
383
  * @description Converts a PDF file to HTML.
272
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
273
- * @param {string=} outputFile - Filepath of the file to output the results to.
384
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
385
+ * @param {string} [outputFile] - Filepath of the file to output the results to.
274
386
  * If `undefined` then Poppler will use the directory and name of the original file
275
387
  * and create a new file, with `-html` appended to the end of the filename.
276
388
  *
277
389
  * Required if `file` is a Buffer.
278
- * @param {object=} options - Object containing options to pass to binary.
279
- * @param {boolean=} options.complexOutput - Generate complex output.
280
- * @param {boolean=} options.dataUrls - Use data URLs instead of external images in HTML.
281
- * @param {boolean=} options.exchangePdfLinks - Exchange .pdf links with .html.
282
- * @param {boolean=} options.extractHidden - Force hidden text extraction.
283
- * @param {number=} options.firstPageToConvert - First page to print.
284
- * @param {boolean=} options.fontFullName - Outputs the font name without any substitutions.
285
- * @param {boolean=} options.ignoreImages - Ignore images.
286
- * @param {('PNG'|'JPG')=} options.imageFormat - Image file format for Splash output (PNG or JPG).
390
+ * @param {object} [options] - Object containing options to pass to binary.
391
+ * @param {boolean} [options.complexOutput] - Generate complex output.
392
+ * @param {boolean} [options.dataUrls] - Use data URLs instead of external images in HTML.
393
+ * @param {boolean} [options.exchangePdfLinks] - Exchange .pdf links with .html.
394
+ * @param {boolean} [options.extractHidden] - Force hidden text extraction.
395
+ * @param {number} [options.firstPageToConvert] - First page to print.
396
+ * @param {boolean} [options.fontFullName] - Outputs the font name without any substitutions.
397
+ * @param {boolean} [options.ignoreImages] - Ignore images.
398
+ * @param {('JPG'|'PNG')} [options.imageFormat] - Image file format for Splash output (JPG or PNG).
287
399
  * If complexOutput is selected, but imageFormat is not specified, PNG will be assumed.
288
- * @param {number=} options.lastPageToConvert - Last page to print.
289
- * @param {boolean=} options.noDrm - Override document DRM settings.
290
- * @param {boolean=} options.noFrames - Generate no frames. Not supported in complex output mode.
291
- * @param {boolean=} options.noMergeParagraph - Do not merge paragraphs.
292
- * @param {boolean=} options.noRoundedCoordinates - Do not round coordinates
400
+ * @param {number} [options.lastPageToConvert] - Last page to print.
401
+ * @param {boolean} [options.noDrm] - Override document DRM settings.
402
+ * @param {boolean} [options.noFrames] - Generate no frames. Not supported in complex output mode.
403
+ * @param {boolean} [options.noMergeParagraph] - Do not merge paragraphs.
404
+ * @param {boolean} [options.noRoundedCoordinates] - Do not round coordinates
293
405
  * (with XML output only).
294
- * @param {string=} options.outputEncoding - Sets the encoding to use for text output.
406
+ * @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
295
407
  * This defaults to `UTF-8`.
296
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
297
- * @param {boolean=} options.printVersionInfo - Print copyright and version info.
298
- * @param {boolean=} options.quiet - Do not print any messages or errors.
299
- * @param {boolean=} options.singlePage - generate single HTML that includes all pages.
300
- * @param {boolean=} options.stdout - Use standard output.
301
- * @param {string=} options.userPassword - User password (for encrypted files).
302
- * @param {number=} options.wordBreakThreshold - Adjust the word break threshold percent.
408
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
409
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version info.
410
+ * @param {boolean} [options.quiet] - Do not print any messages or errors.
411
+ * @param {boolean} [options.singlePage] - generate single HTML that includes all pages.
412
+ * @param {boolean} [options.stdout] - Use standard output.
413
+ * @param {string} [options.userPassword] - User password (for encrypted files).
414
+ * @param {number} [options.wordBreakThreshold] - Adjust the word break threshold percent.
303
415
  * Default is 10. Word break occurs when distance between two adjacent characters is greater
304
416
  * than this percent of character height.
305
- * @param {boolean=} options.xmlOutput - Output for XML post-processing.
306
- * @param {number=} options.zoom - Zoom the PDF document (default 1.5).
417
+ * @param {boolean} [options.xmlOutput] - Output for XML post-processing.
418
+ * @param {number} [options.zoom] - Zoom the PDF document (default 1.5).
307
419
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
308
420
  */
309
421
  pdfToHtml(
310
422
  file: Buffer | string,
311
- outputFile?: string | undefined,
312
- options?: object | undefined
423
+ outputFile?: string,
424
+ options?: {
425
+ complexOutput?: boolean;
426
+ dataUrls?: boolean;
427
+ exchangePdfLinks?: boolean;
428
+ extractHidden?: boolean;
429
+ firstPageToConvert?: number;
430
+ fontFullName?: boolean;
431
+ ignoreImages?: boolean;
432
+ imageFormat?: "JPG" | "PNG";
433
+ lastPageToConvert?: number;
434
+ noDrm?: boolean;
435
+ noFrames?: boolean;
436
+ noMergeParagraph?: boolean;
437
+ noRoundedCoordinates?: boolean;
438
+ outputEncoding?: string;
439
+ ownerPassword?: string;
440
+ printVersionInfo?: boolean;
441
+ quiet?: boolean;
442
+ singlePage?: boolean;
443
+ stdout?: boolean;
444
+ userPassword?: string;
445
+ wordBreakThreshold?: number;
446
+ xmlOutput?: boolean;
447
+ zoom?: number;
448
+ }
313
449
  ): Promise<string>;
314
450
  /**
315
451
  * @author Frazer Smith
316
452
  * @description Converts a PDF file to colour image files in Portable Pixmap (PPM) format,
317
453
  * grayscale image files in Portable Graymap (PGM) format, or monochrome image files
318
454
  * in Portable Bitmap (PBM) format.
319
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
455
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
320
456
  * @param {string} outputPath - Filepath to output the results to.
321
- * @param {object=} options - Object containing options to pass to binary.
322
- * @param {('yes'|'no')=} options.antialiasFonts - Enable or disable font anti-aliasing.
457
+ * @param {object} [options] - Object containing options to pass to binary.
458
+ * @param {('no'|'yes')} [options.antialiasFonts] - Enable or disable font anti-aliasing.
323
459
  * This defaults to `yes`.
324
- * @param {('yes'|'no')=} options.antialiasVectors - Enable or disable vector anti-aliasing.
460
+ * @param {('no'|'yes')} [options.antialiasVectors] - Enable or disable vector anti-aliasing.
325
461
  * This defaults to `yes`.
326
- * @param {boolean=} options.cropBox - Uses the crop box rather than media box when
462
+ * @param {boolean} [options.cropBox] - Uses the crop box rather than media box when
327
463
  * generating the files (PNG/JPEG/TIFF only).
328
- * @param {number=} options.cropHeight - Specifies the height of crop area in pixels
464
+ * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels
329
465
  * (image output) or points (vector output).
330
- * @param {number=} options.cropSize - Specifies the size of crop square in pixels
466
+ * @param {number} [options.cropSize] - Specifies the size of crop square in pixels
331
467
  * (image output) or points (vector output).
332
- * @param {number=} options.cropWidth - Specifies the width of crop area in pixels
468
+ * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels
333
469
  * (image output) or points (vector output).
334
- * @param {number=} options.cropXAxis - Specifies the x-coordinate of the crop area top left
470
+ * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left
335
471
  * corner in pixels (image output) or points (vector output).
336
- * @param {number=} options.cropYAxis - Specifies the y-coordinate of the crop area top left
472
+ * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left
337
473
  * corner in pixels (image output) or points (vector output).
338
- * @param {string=} options.defaultCmykProfile - If Poppler is compiled with colour management support, this option
474
+ * @param {string} [options.defaultCmykProfile] - If Poppler is compiled with colour management support, this option
339
475
  * sets the DefaultCMYK color space to the ICC profile stored in the display profile file passed.
340
- * @param {string=} options.defaultGrayProfile - If Poppler is compiled with colour management support, this option
476
+ * @param {string} [options.defaultGrayProfile] - If Poppler is compiled with colour management support, this option
341
477
  * sets the DefaultGray color space to the ICC profile stored in the display profile file passed.
342
- * @param {string=} options.defaultRgbProfile - If Poppler is compiled with colour management support, this option
478
+ * @param {string} [options.defaultRgbProfile] - If Poppler is compiled with colour management support, this option
343
479
  * sets the DefaultRGB color space to the ICC profile stored in the display profile file passed.
344
- * @param {string=} options.displayProfile - If Poppler is compiled with colour management support, this option
480
+ * @param {string} [options.displayProfile] - If Poppler is compiled with colour management support, this option
345
481
  * sets the display profile to the ICC profile stored in the display profile file passed.
346
- * @param {boolean=} options.evenPagesOnly - Generates only the even numbered pages.
347
- * @param {number=} options.firstPageToConvert - Specifies the first page to convert.
348
- * @param {('yes'|'no')=} options.freetype - Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
482
+ * @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages.
483
+ * @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
484
+ * @param {('no'|'yes')} [options.freetype] - Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
349
485
  * This defaults to `yes`.
350
- * @param {boolean=} options.forcePageNumber - Force page number even if there is only one page.
351
- * @param {boolean=} options.grayscaleFile - Generate grayscale PGM file (instead of a color PPM file).
352
- * @param {boolean=} options.hideAnnotations - Hide annotations.
353
- * @param {boolean=} options.jpegFile - Generate JPEG file instead a PPM file.
354
- * @param {number=} options.lastPageToConvert - Specifies the last page to convert.
355
- * @param {boolean=} options.monochromeFile - Generate monochrome PBM file (instead of a color PPM file).
356
- * @param {boolean=} options.oddPagesOnly - Generates only the odd numbered pages.
357
- * @param {string=} options.ownerPassword - Specify the owner password for the PDF file.
486
+ * @param {boolean} [options.forcePageNumber] - Force page number even if there is only one page.
487
+ * @param {boolean} [options.grayscaleFile] - Generate grayscale PGM file (instead of a color PPM file).
488
+ * @param {boolean} [options.hideAnnotations] - Hide annotations.
489
+ * @param {boolean} [options.jpegFile] - Generate JPEG file instead a PPM file.
490
+ * @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
491
+ * @param {boolean} [options.monochromeFile] - Generate monochrome PBM file (instead of a color PPM file).
492
+ * @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages.
493
+ * @param {string} [options.ownerPassword] - Specify the owner password for the PDF file.
358
494
  * Providing this will bypass all security restrictions.
359
- * @param {boolean=} options.pngFile - Generate PNG file instead a PPM file.
360
- * @param {boolean=} options.printProgress - Print progress info as each page is generated.
495
+ * @param {boolean} [options.pngFile] - Generate PNG file instead a PPM file.
496
+ * @param {boolean} [options.printProgress] - Print progress info as each page is generated.
361
497
  * Three space-separated fields are printed to STDERR: the number of the current page, the number
362
498
  * of the last page that will be generated, and the path to the file written to.
363
- * @param {boolean=} options.printVersionInfo - Print copyright and version information.
364
- * @param {boolean=} options.quiet - Do not print any messages or errors.
365
- * @param {number=} options.resolutionXAxis - Specifies the X resolution, in pixels per inch of
499
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version information.
500
+ * @param {boolean} [options.quiet] - Do not print any messages or errors.
501
+ * @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of
366
502
  * image files (or rasterized regions in vector output). The default is 150 PPI.
367
- * @param {number=} options.resolutionXYAxis - Specifies the X and Y resolution, in pixels per
503
+ * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per
368
504
  * inch of image files (or rasterized regions in vector output). The default is 150 PPI.
369
- * @param {number=} options.resolutionYAxis - Specifies the Y resolution, in pixels per inch of
505
+ * @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of
370
506
  * image files (or rasterized regions in vector output). The default is 150 PPI.
371
- * @param {number=} options.scalePageTo - Scales the long side of each page (width for landscape
507
+ * @param {number} [options.scalePageTo] - Scales the long side of each page (width for landscape
372
508
  * pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will
373
509
  * be determined by the aspect ratio of the page.
374
- * @param {number=} options.scalePageToXAxis - Scales each page horizontally to fit in scale-to-x
510
+ * @param {number} [options.scalePageToXAxis] - Scales each page horizontally to fit in scale-to-x
375
511
  * pixels. If scale-to-y is set to -1, the vertical size will determined by the aspect ratio of
376
512
  * the page.
377
- * @param {number=} options.scalePageToYAxis - Scales each page vertically to fit in scale-to-y
513
+ * @param {number} [options.scalePageToYAxis] - Scales each page vertically to fit in scale-to-y
378
514
  * pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio of
379
515
  * the page.
380
- * @param {string=} options.separator - Specify single character separator between name and page number.
381
- * @param {boolean=} options.singleFile - Writes only the first page and does not add digits.
382
- * @param {('none'|'solid'|'shape')=} options.thinLineMode - Specifies the thin line mode. This defaults to `none`.
383
- * @param {('none'|'packbits'|'jpeg'|'lzw'|'deflate')=} options.tiffCompression - Set TIFF compression.
384
- * @param {boolean=} options.tiffFile - Generate TIFF file instead a PPM file.
385
- * @param {string=} options.userPassword - Specify the user password for the PDF file.
516
+ * @param {string} [options.separator] - Specify single character separator between name and page number.
517
+ * @param {boolean} [options.singleFile] - Writes only the first page and does not add digits.
518
+ * @param {('none'|'shape'|'solid')} [options.thinLineMode] - Specifies the thin line mode. This defaults to `none`.
519
+ * @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression.
520
+ * @param {boolean} [options.tiffFile] - Generate TIFF file instead a PPM file.
521
+ * @param {string} [options.userPassword] - Specify the user password for the PDF file.
386
522
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
387
523
  */
388
524
  pdfToPpm(
389
525
  file: Buffer | string,
390
526
  outputPath: string,
391
- options?: object | undefined
527
+ options?: {
528
+ antialiasFonts?: "no" | "yes";
529
+ antialiasVectors?: "no" | "yes";
530
+ cropBox?: boolean;
531
+ cropHeight?: number;
532
+ cropSize?: number;
533
+ cropWidth?: number;
534
+ cropXAxis?: number;
535
+ cropYAxis?: number;
536
+ defaultCmykProfile?: string;
537
+ defaultGrayProfile?: string;
538
+ defaultRgbProfile?: string;
539
+ displayProfile?: string;
540
+ evenPagesOnly?: boolean;
541
+ firstPageToConvert?: number;
542
+ freetype?: "no" | "yes";
543
+ forcePageNumber?: boolean;
544
+ grayscaleFile?: boolean;
545
+ hideAnnotations?: boolean;
546
+ jpegFile?: boolean;
547
+ lastPageToConvert?: number;
548
+ monochromeFile?: boolean;
549
+ oddPagesOnly?: boolean;
550
+ ownerPassword?: string;
551
+ pngFile?: boolean;
552
+ printProgress?: boolean;
553
+ printVersionInfo?: boolean;
554
+ quiet?: boolean;
555
+ resolutionXAxis?: number;
556
+ resolutionXYAxis?: number;
557
+ resolutionYAxis?: number;
558
+ scalePageTo?: number;
559
+ scalePageToXAxis?: number;
560
+ scalePageToYAxis?: number;
561
+ separator?: string;
562
+ singleFile?: boolean;
563
+ thinLineMode?: "none" | "shape" | "solid";
564
+ tiffCompression?: "deflate" | "jpeg" | "lzw" | "none" | "packbits";
565
+ tiffFile?: boolean;
566
+ userPassword?: string;
567
+ }
392
568
  ): Promise<string>;
393
569
  /**
394
570
  * @author Frazer Smith
395
571
  * @description Converts a PDF file to PostScript (PS).
396
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
397
- * @param {string=} outputFile - Filepath of the file to output the results to.
572
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
573
+ * @param {string} [outputFile] - Filepath of the file to output the results to.
398
574
  * If `undefined` then will write output to stdout.
399
- * @param {object=} options - Object containing options to pass to binary.
400
- * @param {('yes'|'no')=} options.antialias - Enable anti-aliasing on rasterization, accepts `yes` or `no`.
401
- * @param {boolean=} options.binary - Write binary data in Level 1 PostScript. By default,
575
+ * @param {object} [options] - Object containing options to pass to binary.
576
+ * @param {('no'|'yes')} [options.antialias] - Enable anti-aliasing on rasterization, accepts `no` or `yes`.
577
+ * @param {boolean} [options.binary] - Write binary data in Level 1 PostScript. By default,
402
578
  * pdftops writes hex-encoded data in Level 1 PostScript. Binary data is non-standard in Level 1
403
579
  * PostScript but reduces the file size and can be useful when Level 1 PostScript is required
404
580
  * only for its restricted use of PostScript operators.
405
- * @param {string=} options.defaultCmykProfile - If Poppler is compiled with colour management support, this option
581
+ * @param {string} [options.defaultCmykProfile] - If Poppler is compiled with colour management support, this option
406
582
  * sets the DefaultCMYK color space to the ICC profile stored in the display profile file passed.
407
- * @param {string=} options.defaultGrayProfile - If Poppler is compiled with colour management support, this option
583
+ * @param {string} [options.defaultGrayProfile] - If Poppler is compiled with colour management support, this option
408
584
  * sets the DefaultGray color space to the ICC profile stored in the display profile file passed.
409
- * @param {string=} options.defaultRgbProfile - If Poppler is compiled with colour management support, this option
585
+ * @param {string} [options.defaultRgbProfile] - If Poppler is compiled with colour management support, this option
410
586
  * sets the DefaultRGB color space to the ICC profile stored in the display profile file passed.
411
- * @param {boolean=} options.duplex - Set the Duplex pagedevice entry in the PostScript file.
587
+ * @param {boolean} [options.duplex] - Set the Duplex pagedevice entry in the PostScript file.
412
588
  * This tells duplex-capable printers to enable duplexing.
413
- * @param {boolean=} options.epsFile - Generate an EPS file. An EPS file contains a single image,
589
+ * @param {boolean} [options.epsFile] - Generate an EPS file. An EPS file contains a single image,
414
590
  * so if you use this option with a multi-page PDF file, you must use `options.firstPageToConvert` and
415
591
  * `options.lastPageToConvert` to specify a single page.
416
592
  * The page size options (originalPageSizes, paperSize, paperWidth, paperHeight) can not be used
417
593
  * with this option.
418
- * @param {boolean=} options.fillPage - Expand PDF pages smaller than the paper to fill the
594
+ * @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the
419
595
  * paper. By default, these pages are not scaled.
420
- * @param {number=} options.firstPageToConvert - Specifies the first page to convert.
421
- * @param {number=} options.form - Generate PostScript form which can be imported by software
596
+ * @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
597
+ * @param {number} [options.form] - Generate PostScript form which can be imported by software
422
598
  * that understands forms.
423
599
  * A form contains a single page, so if you use this option with a multi-page PDF file,
424
600
  * you must use `options.firstPageToConvert` and `options.lastPageToConvert` to specify a single page.
425
601
  * The `options.level1` option cannot be used with `options.form`.
426
602
  * No more than one of the mode options (`options.epsFile`, `options.form`) may be given.
427
- * @param {number=} options.lastPageToConvert - Specifies the last page to convert.
428
- * @param {boolean=} options.level1 - Generate Level 1 PostScript. The resulting PostScript
603
+ * @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
604
+ * @param {boolean} [options.level1] - Generate Level 1 PostScript. The resulting PostScript
429
605
  * files will be significantly larger (if they contain images), but will print on Level 1 printers.
430
606
  * This also converts all images to black and white.
431
- * @param {boolean=} options.level1Sep - Generate Level 1 separable PostScript.
607
+ * @param {boolean} [options.level1Sep] - Generate Level 1 separable PostScript.
432
608
  * All colors are converted to CMYK. Images are written with separate stream data for the four components.
433
- * @param {boolean=} options.level2 - Generate Level 2 PostScript.
609
+ * @param {boolean} [options.level2] - Generate Level 2 PostScript.
434
610
  * Level 2 supports color images and image compression. This is the default setting.
435
- * @param {boolean=} options.level2Sep - Generate Level 2 separable PostScript. All colors are
611
+ * @param {boolean} [options.level2Sep] - Generate Level 2 separable PostScript. All colors are
436
612
  * converted to CMYK. The PostScript separation convention operators are used to handle custom (spot) colors.
437
- * @param {boolean=} options.level3 - Generate Level 3 PostScript.
613
+ * @param {boolean} [options.level3] - Generate Level 3 PostScript.
438
614
  * This enables all Level 2 featuresplus CID font embedding.
439
- * @param {boolean=} options.level3Sep - Generate Level 3 separable PostScript.
615
+ * @param {boolean} [options.level3Sep] - Generate Level 3 separable PostScript.
440
616
  * The separation handling is the same as for `options.level2Sep`.
441
- * @param {boolean=} options.noEmbedCIDFonts - By default, any CID PostScript fonts which are
617
+ * @param {boolean} [options.noEmbedCIDFonts] - By default, any CID PostScript fonts which are
442
618
  * embedded in the PDF file are copied into the PostScript file. This option disables that embedding.
443
619
  * No attempt is made to substitute for non-embedded CID PostScript fonts.
444
- * @param {boolean=} options.noEmbedCIDTrueTypeFonts - By default, any CID TrueType fonts which are
620
+ * @param {boolean} [options.noEmbedCIDTrueTypeFonts] - By default, any CID TrueType fonts which are
445
621
  * embedded in the PDF file are copied into the PostScript file. This option disables that embedding.
446
622
  * No attempt is made to substitute for non-embedded CID TrueType fonts.
447
- * @param {boolean=} options.noEmbedTrueTypeFonts - By default, any TrueType fonts which are embedded
623
+ * @param {boolean} [options.noEmbedTrueTypeFonts] - By default, any TrueType fonts which are embedded
448
624
  * in the PDF file are copied into the PostScript file. This option causes pdfToPs to substitute base fonts instead.
449
625
  * Embedded fonts make PostScript files larger, but may be necessary for readable output.
450
626
  * Also, some PostScript interpreters do not have TrueType rasterizers.
451
- * @param {boolean=} options.noEmbedType1Fonts - By default, any Type 1 fonts which are embedded in the PDF file
627
+ * @param {boolean} [options.noEmbedType1Fonts] - By default, any Type 1 fonts which are embedded in the PDF file
452
628
  * are copied into the PostScript file. This option causes pdfToPs to substitute base fonts instead.
453
629
  * Embedded fonts make PostScript files larger, but may be necessary for readable output.
454
- * @param {boolean=} options.noCenter - By default, PDF pages smaller than the paper
630
+ * @param {boolean} [options.noCenter] - By default, PDF pages smaller than the paper
455
631
  * (after any scaling) are centered on the paper. This option causes them to be aligned to
456
632
  * the lower-left corner of the paper instead.
457
- * @param {boolean=} options.noCrop - By default, printing output is cropped to the CropBox
633
+ * @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox
458
634
  * specified in the PDF file. This option disables cropping.
459
- * @param {boolean=} options.noShrink - Do not scale PDF pages which are larger than the paper.
635
+ * @param {boolean} [options.noShrink] - Do not scale PDF pages which are larger than the paper.
460
636
  * By default, pages larger than the paper are shrunk to fit.
461
- * @param {boolean=} options.opi - Generate OPI comments for all images and forms which have OPI information.
462
- * @param {boolean=} options.optimizecolorspace - By default, bitmap images in the PDF pass through to the
637
+ * @param {boolean} [options.opi] - Generate OPI comments for all images and forms which have OPI information.
638
+ * @param {boolean} [options.optimizecolorspace] - By default, bitmap images in the PDF pass through to the
463
639
  * output PostScript in their original color space, which produces predictable results.
464
640
  * This option converts RGB and CMYK images into Gray images if every pixel of the image has equal components.
465
641
  * This can fix problems when doing color separations of PDFs that contain embedded black and
466
642
  * white images encoded as RGB.
467
- * @param {boolean=} options.originalPageSizes - Set the paper size of each page to match
643
+ * @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match
468
644
  * the size specified in the PDF file.
469
- * @param {boolean=} options.overprint - Enable overprinting.
470
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
471
- * @param {number=} options.paperHeight - Set the paper height, in points.
472
- * @param {('letter'|'legal'|'A4'|'A3'|'match')=} options.paperSize - Set the paper size to one of `letter`, `legal`, `A4`,
473
- * or `A3`. This can also be set to `match`, which will set the paper size
645
+ * @param {boolean} [options.overprint] - Enable overprinting.
646
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
647
+ * @param {number} [options.paperHeight] - Set the paper height, in points.
648
+ * @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - Set the paper size to one of `A3`, `A4`,
649
+ * `legal`, or `letter`. This can also be set to `match`, which will set the paper size
474
650
  * of each page to match the size specified in the PDF file. If none of the paperSize,
475
651
  * paperWidth, or paperHeight options are specified the default is to match the paper size.
476
- * @param {number=} options.paperWidth - Set the paper width, in points.
477
- * @param {boolean=} options.passfonts - By default, references to non-embedded 8-bit fonts
652
+ * @param {number} [options.paperWidth] - Set the paper width, in points.
653
+ * @param {boolean} [options.passfonts] - By default, references to non-embedded 8-bit fonts
478
654
  * in the PDF file are substituted with the closest `Helvetica`, `Times-Roman`, or `Courier` font.
479
655
  * This option passes references to non-embedded fonts through to the PostScript file.
480
- * @param {boolean=} options.preload - Preload images and forms.
481
- * @param {boolean=} options.printVersionInfo - Print copyright and version information.
482
- * @param {('CMYK8'|'MONO8'|'RGB8')=} options.processColorFormat - Sets the process color format as it is used
656
+ * @param {boolean} [options.preload] - Preload images and forms.
657
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version information.
658
+ * @param {('CMYK8'|'MONO8'|'RGB8')} [options.processColorFormat] - Sets the process color format as it is used
483
659
  * during rasterization and transparency reduction.
484
660
  *
485
661
  * The default depends on the other settings: For `options.level1` the default is MONO8; for `options.level1Sep`,
486
662
  * `options.level2Sep`, `options.level3Sep`, or `options.overprint` the default is CMYK8; in all other
487
663
  * cases RGB8 is the default.
488
664
  * If `option.processColorProfile` is set then `options.processColorFormat` is inferred from the specified ICC profile.
489
- * @param {string=} options.processColorProfile - Sets the ICC profile that is assumed during
665
+ * @param {string} [options.processColorProfile] - Sets the ICC profile that is assumed during
490
666
  * rasterization and transparency reduction.
491
- * @param {boolean=} options.quiet - Do not print any messages or errors.
492
- * @param {('always'|'never'|'whenneeded')=} options.rasterize - By default, pdfToPs rasterizes pages as needed,
667
+ * @param {boolean} [options.quiet] - Do not print any messages or errors.
668
+ * @param {('always'|'never'|'whenneeded')} [options.rasterize] - By default, pdfToPs rasterizes pages as needed,
493
669
  * for example, if they contain transparencies. To force rasterization, set `rasterize` to `always`.
494
670
  * Use this to eliminate fonts.
495
671
  * To prevent rasterization, set `rasterize` to `never`.
496
672
  * This may produce files that display incorrectly.
497
- * @param {number=} options.resolutionXYAxis - Specifies the X and Y resolution, in pixels per
673
+ * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per
498
674
  * inch of image files (or rasterized regions in vector output). The default is 300 PPI.
499
- * @param {string=} options.userPassword - User password (for encrypted files).
675
+ * @param {string} [options.userPassword] - User password (for encrypted files).
500
676
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
501
677
  */
502
678
  pdfToPs(
503
679
  file: Buffer | string,
504
- outputFile?: string | undefined,
505
- options?: object | undefined
680
+ outputFile?: string,
681
+ options?: {
682
+ antialias?: "no" | "yes";
683
+ binary?: boolean;
684
+ defaultCmykProfile?: string;
685
+ defaultGrayProfile?: string;
686
+ defaultRgbProfile?: string;
687
+ duplex?: boolean;
688
+ epsFile?: boolean;
689
+ fillPage?: boolean;
690
+ firstPageToConvert?: number;
691
+ form?: number;
692
+ lastPageToConvert?: number;
693
+ level1?: boolean;
694
+ level1Sep?: boolean;
695
+ level2?: boolean;
696
+ level2Sep?: boolean;
697
+ level3?: boolean;
698
+ level3Sep?: boolean;
699
+ noEmbedCIDFonts?: boolean;
700
+ noEmbedCIDTrueTypeFonts?: boolean;
701
+ noEmbedTrueTypeFonts?: boolean;
702
+ noEmbedType1Fonts?: boolean;
703
+ noCenter?: boolean;
704
+ noCrop?: boolean;
705
+ noShrink?: boolean;
706
+ opi?: boolean;
707
+ optimizecolorspace?: boolean;
708
+ originalPageSizes?: boolean;
709
+ overprint?: boolean;
710
+ ownerPassword?: string;
711
+ paperHeight?: number;
712
+ paperSize?: "A3" | "A4" | "legal" | "letter" | "match";
713
+ paperWidth?: number;
714
+ passfonts?: boolean;
715
+ preload?: boolean;
716
+ printVersionInfo?: boolean;
717
+ processColorFormat?: "CMYK8" | "MONO8" | "RGB8";
718
+ processColorProfile?: string;
719
+ quiet?: boolean;
720
+ rasterize?: "always" | "never" | "whenneeded";
721
+ resolutionXYAxis?: number;
722
+ userPassword?: string;
723
+ }
506
724
  ): Promise<string>;
507
725
  /**
508
726
  * @author Frazer Smith
509
727
  * @description Converts a PDF file to TXT.
510
- * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read.
511
- * @param {string=} outputFile - Filepath of the file to output the results to.
728
+ * @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
729
+ * @param {string} [outputFile] - Filepath of the file to output the results to.
512
730
  * If `undefined` then will write output to stdout.
513
- * @param {object=} options - Object containing options to pass to binary.
514
- * @param {boolean=} options.boundingBoxXhtml - Generate an XHTML file containing bounding
731
+ * @param {object} [options] - Object containing options to pass to binary.
732
+ * @param {boolean} [options.boundingBoxXhtml] - Generate an XHTML file containing bounding
515
733
  * box information for each word in the file.
516
- * @param {boolean=} options.boundingBoxXhtmlLayout - Generate an XHTML file containing
734
+ * @param {boolean} [options.boundingBoxXhtmlLayout] - Generate an XHTML file containing
517
735
  * bounding box information for each block, line, and word in the file.
518
- * @param {boolean=} options.cropBox - Use the crop box rather than the media box with
736
+ * @param {boolean} [options.cropBox] - Use the crop box rather than the media box with
519
737
  * `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout`
520
- * @param {number=} options.cropHeight - Specifies the height of crop area in pixels
738
+ * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels
521
739
  * (image output) or points (vector output).
522
- * @param {number=} options.cropWidth - Specifies the width of crop area in pixels
740
+ * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels
523
741
  * (image output) or points (vector output).
524
- * @param {number=} options.cropXAxis - Specifies the x-coordinate of the crop area top left
742
+ * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left
525
743
  * corner in pixels (image output) or points (vector output).
526
- * @param {number=} options.cropYAxis - Specifies the y-coordinate of the crop area top left
744
+ * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left
527
745
  * corner in pixels (image output) or points (vector output).
528
- * @param {('unix'|'dos'|'mac')=} options.eolConvention - Sets the end-of-line convention to use for
529
- * text output: unix; dos; mac.
530
- * @param {number=} options.firstPageToConvert - Specifies the first page to convert.
531
- * @param {number=} options.fixedWidthLayout - Assume fixed-pitch (or tabular) text, with the
746
+ * @param {('dos'|'mac'|'unix')} [options.eolConvention] - Sets the end-of-line convention to use for
747
+ * text output: dos; mac; unix.
748
+ * @param {number} [options.firstPageToConvert] - Specifies the first page to convert.
749
+ * @param {number} [options.fixedWidthLayout] - Assume fixed-pitch (or tabular) text, with the
532
750
  * specified character width (in points). This forces physical layout mode.
533
- * @param {boolean=} options.generateHtmlMetaFile - Generate simple HTML file, including the
751
+ * @param {boolean} [options.generateHtmlMetaFile] - Generate simple HTML file, including the
534
752
  * meta information. This simply wraps the text in `<pre>` and `</pre>` and prepends the meta headers.
535
- * @param {boolean=} options.generateTsvFile - Generate a TSV file containing the bounding box
753
+ * @param {boolean} [options.generateTsvFile] - Generate a TSV file containing the bounding box
536
754
  * information for each block, line, and word in the file.
537
- * @param {number=} options.lastPageToConvert - Specifies the last page to convert.
538
- * @param {boolean=} options.listEncodingOptions - List the available encodings.
539
- * @param {boolean=} options.maintainLayout - Maintain (as best as possible) the original physical
755
+ * @param {number} [options.lastPageToConvert] - Specifies the last page to convert.
756
+ * @param {boolean} [options.listEncodingOptions] - List the available encodings.
757
+ * @param {boolean} [options.maintainLayout] - Maintain (as best as possible) the original physical
540
758
  * layout of the text. The default is to undo physical layout (columns, hyphenation, etc.) and
541
759
  * output the text in reading order.
542
- * @param {boolean=} options.noDiagonalText - Discard diagonal text.
543
- * @param {boolean=} options.noPageBreaks - Do not insert page breaks (form feed characters)
760
+ * @param {boolean} [options.noDiagonalText] - Discard diagonal text.
761
+ * @param {boolean} [options.noPageBreaks] - Do not insert page breaks (form feed characters)
544
762
  * between pages.
545
- * @param {string=} options.outputEncoding - Sets the encoding to use for text output.
763
+ * @param {string} [options.outputEncoding] - Sets the encoding to use for text output.
546
764
  * This defaults to `UTF-8`.
547
- * @param {string=} options.ownerPassword - Owner password (for encrypted files).
548
- * @param {boolean=} options.printVersionInfo - Print copyright and version information.
549
- * @param {boolean=} options.quiet - Do not print any messages or errors.
550
- * @param {boolean=} options.rawLayout - Keep the text in content stream order. This is a
765
+ * @param {string} [options.ownerPassword] - Owner password (for encrypted files).
766
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version information.
767
+ * @param {boolean} [options.quiet] - Do not print any messages or errors.
768
+ * @param {boolean} [options.rawLayout] - Keep the text in content stream order. This is a
551
769
  * hack which often undoes column formatting, etc. Use of raw mode is no longer recommended.
552
- * @param {string=} options.userPassword - User password (for encrypted files).
770
+ * @param {string} [options.userPassword] - User password (for encrypted files).
553
771
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
554
772
  */
555
773
  pdfToText(
556
774
  file: Buffer | string,
557
- outputFile?: string | undefined,
558
- options?: object | undefined
775
+ outputFile?: string,
776
+ options?: {
777
+ boundingBoxXhtml?: boolean;
778
+ boundingBoxXhtmlLayout?: boolean;
779
+ cropBox?: boolean;
780
+ cropHeight?: number;
781
+ cropWidth?: number;
782
+ cropXAxis?: number;
783
+ cropYAxis?: number;
784
+ eolConvention?: "dos" | "mac" | "unix";
785
+ firstPageToConvert?: number;
786
+ fixedWidthLayout?: number;
787
+ generateHtmlMetaFile?: boolean;
788
+ generateTsvFile?: boolean;
789
+ lastPageToConvert?: number;
790
+ listEncodingOptions?: boolean;
791
+ maintainLayout?: boolean;
792
+ noDiagonalText?: boolean;
793
+ noPageBreaks?: boolean;
794
+ outputEncoding?: string;
795
+ ownerPassword?: string;
796
+ printVersionInfo?: boolean;
797
+ quiet?: boolean;
798
+ rawLayout?: boolean;
799
+ userPassword?: string;
800
+ }
559
801
  ): Promise<string>;
560
802
  /**
561
803
  * @author Frazer Smith
562
804
  * @description Merges several PDF files in order of their occurrence in the files array to
563
805
  * one PDF result file.
564
- * @param {Array} files - Filepaths of the PDF files to merge.
806
+ * @param {string[]} files - Filepaths of the PDF files to merge.
565
807
  * An entire directory of PDF files can be merged like so: `path/to/directory/*.pdf`.
566
808
  * @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
567
- * @param {object=} options - Object containing options to pass to binary.
568
- * @param {boolean=} options.printVersionInfo - Print copyright and version information.
809
+ * @param {object} [options] - Object containing options to pass to binary.
810
+ * @param {boolean} [options.printVersionInfo] - Print copyright and version information.
569
811
  * @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
570
812
  */
571
813
  pdfUnite(
572
- files: any[],
814
+ files: string[],
573
815
  outputFile: string,
574
- options?: object | undefined
816
+ options?: {
817
+ printVersionInfo?: boolean;
818
+ }
575
819
  ): Promise<string>;
576
820
  }