node-poppler 9.0.1 → 9.1.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/package.json +2 -1
- package/src/index.js +547 -444
- package/types/index.d.ts +30 -12
package/types/index.d.ts
CHANGED
|
@@ -1114,6 +1114,12 @@ export type PdfUniteOptions = {
|
|
|
1114
1114
|
*/
|
|
1115
1115
|
printVersionInfo?: boolean | undefined;
|
|
1116
1116
|
};
|
|
1117
|
+
export type PopplerExtraOptions = {
|
|
1118
|
+
/**
|
|
1119
|
+
* An `AbortSignal` that can be used to cancel the operation.
|
|
1120
|
+
*/
|
|
1121
|
+
signal?: AbortSignal | undefined;
|
|
1122
|
+
};
|
|
1117
1123
|
export class Poppler {
|
|
1118
1124
|
/**
|
|
1119
1125
|
* @param {string} [binPath] - Path of poppler-utils binaries.
|
|
@@ -1136,43 +1142,48 @@ export class Poppler {
|
|
|
1136
1142
|
* @param {string} fileToAttach - Filepath of the attachment to be embedded into the PDF file.
|
|
1137
1143
|
* @param {string} outputFile - Filepath of the file to output the results to.
|
|
1138
1144
|
* @param {PdfAttachOptions} [options] - Options to pass to pdfattach binary.
|
|
1145
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1139
1146
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1140
1147
|
*/
|
|
1141
|
-
pdfAttach(file: string, fileToAttach: string, outputFile: string, options?: PdfAttachOptions): Promise<string>;
|
|
1148
|
+
pdfAttach(file: string, fileToAttach: string, outputFile: string, options?: PdfAttachOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1142
1149
|
/**
|
|
1143
1150
|
* @author Frazer Smith
|
|
1144
1151
|
* @description Lists or extracts embedded files (attachments) from a PDF file.
|
|
1145
1152
|
* @param {string} file - Filepath of the PDF file to read.
|
|
1146
1153
|
* @param {PdfDetachOptions} [options] - Options to pass to pdfdetach binary.
|
|
1154
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1147
1155
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1148
1156
|
*/
|
|
1149
|
-
pdfDetach(file: string, options?: PdfDetachOptions): Promise<string>;
|
|
1157
|
+
pdfDetach(file: string, options?: PdfDetachOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1150
1158
|
/**
|
|
1151
1159
|
* @author Frazer Smith
|
|
1152
1160
|
* @description Lists the fonts used in a PDF file along with various information for each font.
|
|
1153
1161
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1154
1162
|
* @param {PdfFontsOptions} [options] - Options to pass to pdffonts binary.
|
|
1163
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1155
1164
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1156
1165
|
*/
|
|
1157
|
-
pdfFonts(file: (Buffer | string), options?: PdfFontsOptions): Promise<string>;
|
|
1166
|
+
pdfFonts(file: (Buffer | string), options?: PdfFontsOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1158
1167
|
/**
|
|
1159
1168
|
* @author Frazer Smith
|
|
1160
1169
|
* @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files.
|
|
1161
1170
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1162
1171
|
* @param {string} [outputPrefix] - Filename prefix of output files.
|
|
1163
1172
|
* @param {PdfImagesOptions} [options] - Options to pass to pdfimages binary.
|
|
1173
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1164
1174
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1165
1175
|
*/
|
|
1166
|
-
pdfImages(file: (Buffer | string), outputPrefix?: string, options?: PdfImagesOptions): Promise<string>;
|
|
1176
|
+
pdfImages(file: (Buffer | string), outputPrefix?: string, options?: PdfImagesOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1167
1177
|
/**
|
|
1168
1178
|
* @author Frazer Smith
|
|
1169
1179
|
* @description Prints the contents of the `Info` dictionary from a PDF file.
|
|
1170
1180
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1171
1181
|
* @param {PdfInfoOptions} [options] - Options to pass to pdfinfo binary.
|
|
1182
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1172
1183
|
* @returns {Promise<object|string>} A promise that resolves with a stdout string or JSON object if
|
|
1173
1184
|
* `options.printAsJson` is `true`, or rejects with an `Error` object.
|
|
1174
1185
|
*/
|
|
1175
|
-
pdfInfo(file: (Buffer | string), options?: PdfInfoOptions): Promise<object | string>;
|
|
1186
|
+
pdfInfo(file: (Buffer | string), options?: PdfInfoOptions, extras?: PopplerExtraOptions): Promise<object | string>;
|
|
1176
1187
|
/**
|
|
1177
1188
|
* @author Frazer Smith
|
|
1178
1189
|
* @description Extracts single pages from a PDF file,
|
|
@@ -1183,9 +1194,10 @@ export class Poppler {
|
|
|
1183
1194
|
* since %d is replaced by the page number.
|
|
1184
1195
|
* As an example, `sample-%d.pdf` will produce `sample-1.pdf` for a single page document.
|
|
1185
1196
|
* @param {PdfSeparateOptions} [options] - Options to pass to pdfseparate binary.
|
|
1197
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1186
1198
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1187
1199
|
*/
|
|
1188
|
-
pdfSeparate(file: string, outputPattern: string, options?: PdfSeparateOptions): Promise<string>;
|
|
1200
|
+
pdfSeparate(file: string, outputPattern: string, options?: PdfSeparateOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1189
1201
|
/**
|
|
1190
1202
|
* @author Frazer Smith
|
|
1191
1203
|
* @description Converts a PDF file to EPS/JPEG/PDF/PNG/PS/SVG/TIFF.
|
|
@@ -1198,9 +1210,10 @@ export class Poppler {
|
|
|
1198
1210
|
*
|
|
1199
1211
|
* If not set then the output filename will be derived from the PDF file name.
|
|
1200
1212
|
* @param {PdfToCairoOptions} [options] - Options to pass to pdftocairo binary.
|
|
1213
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1201
1214
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1202
1215
|
*/
|
|
1203
|
-
pdfToCairo(file: Buffer | string, outputFile?: string, options?: PdfToCairoOptions): Promise<string>;
|
|
1216
|
+
pdfToCairo(file: Buffer | string, outputFile?: string, options?: PdfToCairoOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1204
1217
|
/**
|
|
1205
1218
|
* @author Frazer Smith
|
|
1206
1219
|
* @description Converts a PDF file to HTML.
|
|
@@ -1211,9 +1224,10 @@ export class Poppler {
|
|
|
1211
1224
|
*
|
|
1212
1225
|
* Required if `file` is a Buffer.
|
|
1213
1226
|
* @param {PdfToHtmlOptions} [options] - Options to pass to pdftohtml binary.
|
|
1227
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1214
1228
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1215
1229
|
*/
|
|
1216
|
-
pdfToHtml(file: (Buffer | string), outputFile?: string, options?: PdfToHtmlOptions): Promise<string>;
|
|
1230
|
+
pdfToHtml(file: (Buffer | string), outputFile?: string, options?: PdfToHtmlOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1217
1231
|
/**
|
|
1218
1232
|
* @author Frazer Smith
|
|
1219
1233
|
* @description Converts a PDF file to colour image files in Portable Pixmap (PPM) format,
|
|
@@ -1222,9 +1236,10 @@ export class Poppler {
|
|
|
1222
1236
|
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
|
|
1223
1237
|
* @param {string} outputPath - Filepath to output the results to.
|
|
1224
1238
|
* @param {PdfToPpmOptions} [options] - Options to pass to pdftoppm binary.
|
|
1239
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1225
1240
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1226
1241
|
*/
|
|
1227
|
-
pdfToPpm(file: (Buffer | string), outputPath: string, options?: PdfToPpmOptions): Promise<string>;
|
|
1242
|
+
pdfToPpm(file: (Buffer | string), outputPath: string, options?: PdfToPpmOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1228
1243
|
/**
|
|
1229
1244
|
* @author Frazer Smith
|
|
1230
1245
|
* @description Converts a PDF file to PostScript (PS).
|
|
@@ -1232,9 +1247,10 @@ export class Poppler {
|
|
|
1232
1247
|
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1233
1248
|
* If `undefined` then will write output to stdout.
|
|
1234
1249
|
* @param {PdfToPsOptions} [options] - Options to pass to pdftops binary.
|
|
1250
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1235
1251
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1236
1252
|
*/
|
|
1237
|
-
pdfToPs(file: (Buffer | string), outputFile?: string, options?: PdfToPsOptions): Promise<string>;
|
|
1253
|
+
pdfToPs(file: (Buffer | string), outputFile?: string, options?: PdfToPsOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1238
1254
|
/**
|
|
1239
1255
|
* @author Frazer Smith
|
|
1240
1256
|
* @description Converts a PDF file to TXT.
|
|
@@ -1242,9 +1258,10 @@ export class Poppler {
|
|
|
1242
1258
|
* @param {string} [outputFile] - Filepath of the file to output the results to.
|
|
1243
1259
|
* If `undefined` then will write output to stdout.
|
|
1244
1260
|
* @param {PdfToTextOptions} [options] - Options to pass to pdftotext binary.
|
|
1261
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1245
1262
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1246
1263
|
*/
|
|
1247
|
-
pdfToText(file: (Buffer | string), outputFile?: string, options?: PdfToTextOptions): Promise<string>;
|
|
1264
|
+
pdfToText(file: (Buffer | string), outputFile?: string, options?: PdfToTextOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1248
1265
|
/**
|
|
1249
1266
|
* @author Frazer Smith
|
|
1250
1267
|
* @description Merges several PDF files in order of their occurrence in the files array to
|
|
@@ -1253,8 +1270,9 @@ export class Poppler {
|
|
|
1253
1270
|
* An entire directory of PDF files can be merged like so: `path/to/directory/*.pdf`.
|
|
1254
1271
|
* @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
|
|
1255
1272
|
* @param {PdfUniteOptions} [options] - Options to pass to pdfunite binary.
|
|
1273
|
+
* @param {PopplerExtraOptions} [extras] - Extra options.
|
|
1256
1274
|
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
|
|
1257
1275
|
*/
|
|
1258
|
-
pdfUnite(files: string[], outputFile: string, options?: PdfUniteOptions): Promise<string>;
|
|
1276
|
+
pdfUnite(files: string[], outputFile: string, options?: PdfUniteOptions, extras?: PopplerExtraOptions): Promise<string>;
|
|
1259
1277
|
#private;
|
|
1260
1278
|
}
|