node-poppler
Version:
Asynchronous Node.js wrapper for the Poppler PDF rendering library
1,279 lines (1,278 loc) • 48.1 kB
TypeScript
export default Poppler;
export type OptionDetails = {
/**
* The argument to pass to the binary.
*/
arg: string;
/**
* The type of the option.
*/
type: ("boolean" | "number" | "string");
/**
* The minimum version of the binary that supports this option.
*/
minVersion?: string | undefined;
/**
* The maximum version of the binary that supports this option (optional).
*/
maxVersion?: string | undefined;
};
export type PopplerAcceptedOptions = Record<string, OptionDetails>;
export type PdfAttachOptions = {
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* Replace embedded file with same name (if it exists).
*/
replace?: boolean | undefined;
};
export type PdfDetachOptions = {
/**
* List all of the embedded files in the PDF file.
* File names are converted to the text encoding specified by `options.outputEncoding`.
*/
listEmbedded?: boolean | undefined;
/**
* Sets the encoding to use for text output.
* This defaults to `UTF-8`.
*/
outputEncoding?: string | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Set the file name used when saving an embedded file with
* the save option enabled, or the directory if `options.saveall` is used.
*/
outputPath?: string | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* Save all of the embedded files. This uses the file
* names associated with the embedded files (as printed by `options.listEmbedded`).
* By default, the files are saved in the current directory; this can be changed
* with `options.outputPath`.
*/
saveAllFiles?: boolean | undefined;
/**
* Save the specified embedded file.
* By default, this uses the file name associated with the embedded file (as printed by
* `options.listEmbedded`); the file name can be changed with `options.outputPath`.
*/
saveFile?: string | undefined;
/**
* Save the specified embedded file.
* By default, this uses the file name associated with the embedded file (as printed by
* `options.listEmbedded`); the file name can be changed with `options.outputPath`.
*/
saveSpecificFile?: number | undefined;
/**
* User password (for encrypted files).
*/
userPassword?: string | undefined;
};
export type PdfFontsOptions = {
/**
* Specifies the first page to examine.
*/
firstPageToExamine?: number | undefined;
/**
* Specifies the last page to examine.
*/
lastPageToExamine?: number | undefined;
/**
* List the substitute fonts that poppler
* will use for non-embedded fonts.
*/
listSubstitutes?: boolean | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* User password (for encrypted files).
*/
userPassword?: string | undefined;
};
export type PdfImagesOptions = {
/**
* Write JPEG, JPEG2000, JBIG2, and CCITT images in their native format.
* CMYK files are written as TIFF files. All other images are written as PNG files.
*/
allFiles?: boolean | undefined;
/**
* Generate CCITT images as CCITT files.
*/
ccittFile?: boolean | undefined;
/**
* Specifies the first page to convert.
*/
firstPageToConvert?: number | undefined;
/**
* Specifies the last page to convert.
*/
lastPageToConvert?: number | undefined;
/**
* Generate JBIG2 images as JBIG2 files.
*/
jbig2File?: boolean | undefined;
/**
* Generate JPEG2000 images at JP2 files.
*/
jpeg2000File?: boolean | undefined;
/**
* Generate JPEG images as JPEG files.
*/
jpegFile?: boolean | undefined;
/**
* Instead of writing the images, list the
* images along with various information for each image.
* NOTE: Do not specify the outputPrefix with this option.
*/
list?: boolean | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Change the default output format to PNG.
*/
pngFile?: boolean | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* Change the default output format to TIFF.
*/
tiffFile?: boolean | undefined;
/**
* Specify the user password for the PDF file.
*/
userPassword?: string | undefined;
};
export type PdfInfoOptions = {
/**
* First page to print.
*/
firstPageToConvert?: number | undefined;
/**
* Last page to print.
*/
lastPageToConvert?: number | undefined;
/**
* List the available encodings.
*/
listEncodingOptions?: boolean | undefined;
/**
* Sets the encoding to use for text output.
* This defaults to `UTF-8`.
*/
outputEncoding?: string | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Print result as a JSON object.
*/
printAsJson?: boolean | undefined;
/**
* Prints the page box bounding boxes:
* MediaBox, CropBox, BleedBox, TrimBox, and ArtBox.
*/
printBoundingBoxes?: boolean | undefined;
/**
* Prints the logical document structure
* of a Tagged-PDF file.
*/
printDocStruct?: boolean | undefined;
/**
* Print the textual content along with the
* document structure of a Tagged-PDF file. Note that extracting text this way might be slow
* for big PDF files.
*/
printDocStructText?: boolean | undefined;
/**
* Prints dates in ISO-8601 format (including the time zone).
*/
printIsoDates?: boolean | undefined;
/**
* Prints all JavaScript in the PDF file.
*/
printJS?: boolean | undefined;
/**
* Prints document-level metadata. (This is the `Metadata`
* stream from the PDF file's Catalog object).
*/
printMetadata?: boolean | undefined;
/**
* Print a list of all named destinations. If a page range
* is specified using the `options.firstPageToConvert` and `options.lastPageToConvert` options, only destinations
* in the page range are listed.
*/
printNamedDests?: boolean | undefined;
/**
* Prints the raw (undecoded) date strings, directly from the PDF file.
*/
printRawDates?: boolean | undefined;
/**
* Print all URLs in the PDF; only URLs referenced by PDF objects
* such as Link Annotations are listed, not URL strings in the text content.
*/
printUrls?: boolean | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* User password (for encrypted files).
*/
userPassword?: string | undefined;
};
export type PdfSeparateOptions = {
/**
* Specifies the first page to extract.
* This defaults to page 1.
*/
firstPageToExtract?: number | undefined;
/**
* Specifies the last page to extract.
* This defaults to the last page of the PDF file.
*/
lastPageToExtract?: number | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
};
export type PdfToCairoOptions = {
/**
* Set the cairo
* antialias option used for text and drawing in image files (or rasterized regions in vector output).
*/
antialias?: "best" | "default" | "fast" | "good" | "gray" | "none" | "subpixel" | undefined;
/**
* Uses the crop box rather than media box when
* generating the files (PNG/JPEG/TIFF only).
*/
cropBox?: boolean | undefined;
/**
* Specifies the height of crop area in pixels
* (image output) or points (vector output).
*/
cropHeight?: number | undefined;
/**
* Specifies the size of crop square in pixels
* (image output) or points (vector output).
*/
cropSize?: number | undefined;
/**
* Specifies the width of crop area in pixels
* (image output) or points (vector output).
*/
cropWidth?: number | undefined;
/**
* Specifies the x-coordinate of the crop area top left
* corner in pixels (image output) or points (vector output).
*/
cropXAxis?: number | undefined;
/**
* Specifies the y-coordinate of the crop area top left
* corner in pixels (image output) or points (vector output).
*/
cropYAxis?: number | undefined;
/**
* Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC
* comment to the PostScript file (PS only). This tells the print manager to enable duplexing.
*/
duplex?: boolean | undefined;
/**
* Generate an EPS file. An EPS file contains a single image,
* so if you use this option with a multi-page PDF file, you must use `options.firstPageToConvert` and
* `options.lastPageToConvert` to specify a single page.
* The page size options (originalPageSizes, paperSize, paperWidth, paperHeight) can not be used
* with this option.
*/
epsFile?: boolean | undefined;
/**
* Generates only the even numbered pages.
*/
evenPagesOnly?: boolean | undefined;
/**
* Expand PDF pages smaller than the paper to fill the
* paper (PS,PDF,SVG only). By default, these pages are not scaled.
*/
fillPage?: boolean | undefined;
/**
* Specifies the first page to convert.
*/
firstPageToConvert?: number | undefined;
/**
* Generate grayscale file (PNG, JPEG, and TIFF only).
*/
grayscaleFile?: boolean | undefined;
/**
* Use the specified ICC file as the output profile
* (PNG only). The profile will be embedded in the PNG file.
*/
iccFile?: string | undefined;
/**
* Generate JPEG file(s).
*/
jpegFile?: boolean | undefined;
/**
* When used with `options.jpegFile`, this option can
* be used to control the JPEG compression parameters. It takes a string of the form
* `"<opt>=<val>[,<opt>=<val>]"`. Currently available options are:
* - `quality` Selects the JPEG quality value. The value must be an integer between 0 and 100.
* - `progressive` Select progressive JPEG output. The possible values are "y", "n", indicating
* progressive (yes) or non-progressive (no), respectively.
* - `optimize` Sets whether to compute optimal Huffman coding tables for the JPEG output, which
* will create smaller files but make an extra pass over the data. The value must be "y" or "n",
* with "y" performing optimization, otherwise the default Huffman tables are used.
*
* Example: `"quality=95,optimize=y"`.
*/
jpegOptions?: string | undefined;
/**
* Specifies the last page to convert.
*/
lastPageToConvert?: number | undefined;
/**
* Generate monochrome file (PNG and TIFF only).
*/
monochromeFile?: boolean | undefined;
/**
* By default, PDF pages smaller than the paper
* (after any scaling) are centered on the paper. This option causes them to be aligned to
* the lower-left corner of the paper instead (PS,PDF,SVG only).
*/
noCenter?: boolean | undefined;
/**
* By default, printing output is cropped to the CropBox
* specified in the PDF file. This option disables cropping (PS, PDF, SVG only).
*/
noCrop?: boolean | undefined;
/**
* Do not scale PDF pages which are larger than the paper
* (PS,PDF,SVG only). By default, pages larger than the paper are shrunk to fit.
*/
noShrink?: boolean | undefined;
/**
* Generates only the odd numbered pages.
*/
oddPagesOnly?: boolean | undefined;
/**
* Set the paper size of each page to match
* the size specified in the PDF file.
*/
originalPageSizes?: boolean | undefined;
/**
* Specify the owner password for the PDF file.
* Providing this will bypass all security restrictions.
*/
ownerPassword?: string | undefined;
/**
* Set the paper height, in points (PS, PDF, SVG only).
*/
paperHeight?: number | undefined;
/**
* Set the paper size to one of `A3`, `A4`,
* `legal`, or `letter` (PS,PDF,SVG only). This can also be set to `match`, which will set the paper size
* of each page to match the size specified in the PDF file. If none of the paperSize,
* paperWidth, or paperHeight options are specified the default is to match the paper size.
*/
paperSize?: "A3" | "A4" | "legal" | "letter" | "match" | undefined;
/**
* Set the paper width, in points (PS,PDF,SVG only).
*/
paperWidth?: number | undefined;
/**
* Generate PDF file.
*/
pdfFile?: boolean | undefined;
/**
* Generate PNG file(s).
*/
pngFile?: boolean | undefined;
/**
* Print copyright and version information.
*/
printVersionInfo?: boolean | undefined;
/**
* If the input file contains structural information
* about the document's content, write this information to the output file (PDF only).
*/
printDocStruct?: boolean | undefined;
/**
* Generate PS file.
*/
psFile?: boolean | undefined;
/**
* Generate Level 2 PostScript (PS only).
*/
psLevel2?: boolean | undefined;
/**
* Generate Level 3 PostScript (PS only). This enables all
* Level 2 features plus shading patterns and masked images. This is the default setting.
*/
psLevel3?: boolean | undefined;
/**
* Do not print any messages or errors.
*/
quiet?: boolean | undefined;
/**
* Specifies the X resolution, in pixels per inch of
* image files (or rasterized regions in vector output). The default is 150 PPI.
*/
resolutionXAxis?: number | undefined;
/**
* Specifies the X and Y resolution, in pixels per
* inch of image files (or rasterized regions in vector output). The default is 150 PPI.
*/
resolutionXYAxis?: number | undefined;
/**
* Specifies the Y resolution, in pixels per inch of
* image files (or rasterized regions in vector output). The default is 150 PPI.
*/
resolutionYAxis?: number | undefined;
/**
* Scales the long side of each page (width for landscape
* pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will
* be determined by the aspect ratio of the page (PNG/JPEG/TIFF only).
*/
scalePageTo?: number | undefined;
/**
* Scales each page horizontally to fit in scale-to-x
* pixels. If scale-to-y is set to -1, the vertical size will determined by the aspect ratio of
* the page (PNG/JPEG/TIFF only).
*/
scalePageToXAxis?: number | undefined;
/**
* Scales each page vertically to fit in scale-to-y
* pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio of
* the page (PNG/JPEG/TIFF only).
*/
scalePageToYAxis?: number | undefined;
/**
* Writes only the first page and does not add digits.
* Can only be used with `options.jpegFile`, `options.pngFile`, and `options.tiffFile`.
*/
singleFile?: boolean | undefined;
/**
* Generate SVG (Scalable Vector Graphics) file.
*/
svgFile?: boolean | undefined;
/**
* Set TIFF compression.
*/
tiffCompression?: "none" | "deflate" | "jpeg" | "lzw" | "packbits" | undefined;
/**
* Generate TIFF file(s).
*/
tiffFile?: boolean | undefined;
/**
* Use a transparent page color
* instead of white (PNG and TIFF only).
*/
transparentPageColor?: boolean | undefined;
/**
* Specify the user password for the PDF file.
*/
userPassword?: string | undefined;
};
export type PdfToHtmlOptions = {
/**
* Generate complex output.
*/
complexOutput?: boolean | undefined;
/**
* Use data URLs instead of external images in HTML.
*/
dataUrls?: boolean | undefined;
/**
* Exchange .pdf links with .html.
*/
exchangePdfLinks?: boolean | undefined;
/**
* Force hidden text extraction.
*/
extractHidden?: boolean | undefined;
/**
* First page to print.
*/
firstPageToConvert?: number | undefined;
/**
* Outputs the font name without any substitutions.
*/
fontFullName?: boolean | undefined;
/**
* Ignore images.
*/
ignoreImages?: boolean | undefined;
/**
* Image file format for Splash output (JPG or PNG).
* If complexOutput is selected, but imageFormat is not specified, PNG will be assumed.
*/
imageFormat?: "JPG" | "PNG" | undefined;
/**
* Last page to print.
*/
lastPageToConvert?: number | undefined;
/**
* Override document DRM settings.
*/
noDrm?: boolean | undefined;
/**
* Generate no frames. Not supported in complex output mode.
*/
noFrames?: boolean | undefined;
/**
* Do not merge paragraphs.
*/
noMergeParagraph?: boolean | undefined;
/**
* Do not round coordinates
* (with XML output only).
*/
noRoundedCoordinates?: boolean | undefined;
/**
* Sets the encoding to use for text output.
* This defaults to `UTF-8`.
*/
outputEncoding?: string | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* Do not print any messages or errors.
*/
quiet?: boolean | undefined;
/**
* Generate single HTML that includes all pages.
*/
singlePage?: boolean | undefined;
/**
* Use standard output.
*/
stdout?: boolean | undefined;
/**
* User password (for encrypted files).
*/
userPassword?: string | undefined;
/**
* Adjust the word break threshold percent.
* Default is 10. Word break occurs when distance between two adjacent characters is greater
* than this percent of character height.
*/
wordBreakThreshold?: number | undefined;
/**
* Output for XML post-processing.
*/
xmlOutput?: boolean | undefined;
/**
* Zoom the PDF document (default 1.5).
*/
zoom?: number | undefined;
};
export type PdfToPpmOptions = {
/**
* Enable or disable font anti-aliasing.
* This defaults to `yes`.
*/
antialiasFonts?: "no" | "yes" | undefined;
/**
* Enable or disable vector anti-aliasing.
* This defaults to `yes`.
*/
antialiasVectors?: "no" | "yes" | undefined;
/**
* Uses the crop box rather than media box when
* generating the files (PNG/JPEG/TIFF only).
*/
cropBox?: boolean | undefined;
/**
* Specifies the height of crop area in pixels
* (image output) or points (vector output).
*/
cropHeight?: number | undefined;
/**
* Specifies the size of crop square in pixels
* (image output) or points (vector output).
*/
cropSize?: number | undefined;
/**
* Specifies the width of crop area in pixels
* (image output) or points (vector output).
*/
cropWidth?: number | undefined;
/**
* Specifies the x-coordinate of the crop area top left
* corner in pixels (image output) or points (vector output).
*/
cropXAxis?: number | undefined;
/**
* Specifies the y-coordinate of the crop area top left
* corner in pixels (image output) or points (vector output).
*/
cropYAxis?: number | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the DefaultCMYK color space to the ICC profile stored in the display profile file passed.
*/
defaultCmykProfile?: string | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the DefaultGray color space to the ICC profile stored in the display profile file passed.
*/
defaultGrayProfile?: string | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the DefaultRGB color space to the ICC profile stored in the display profile file passed.
*/
defaultRgbProfile?: string | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the display profile to the ICC profile stored in the display profile file passed.
*/
displayProfile?: string | undefined;
/**
* Generates only the even numbered pages.
*/
evenPagesOnly?: boolean | undefined;
/**
* Specifies the first page to convert.
*/
firstPageToConvert?: number | undefined;
/**
* Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
* This defaults to `yes`.
*/
freetype?: "no" | "yes" | undefined;
/**
* Force page number even if there is only one page.
*/
forcePageNumber?: boolean | undefined;
/**
* Generate grayscale PGM file (instead of a color PPM file).
*/
grayscaleFile?: boolean | undefined;
/**
* Hide annotations.
*/
hideAnnotations?: boolean | undefined;
/**
* Generate JPEG file instead a PPM file.
*/
jpegFile?: boolean | undefined;
/**
* Specifies the last page to convert.
*/
lastPageToConvert?: number | undefined;
/**
* Generate monochrome PBM file (instead of a color PPM file).
*/
monochromeFile?: boolean | undefined;
/**
* Generates only the odd numbered pages.
*/
oddPagesOnly?: boolean | undefined;
/**
* Specify the owner password for the PDF file.
* Providing this will bypass all security restrictions.
*/
ownerPassword?: string | undefined;
/**
* Generate PNG file instead a PPM file.
*/
pngFile?: boolean | undefined;
/**
* Print progress info as each page is generated.
* Three space-separated fields are printed to STDERR: the number of the current page, the number
* of the last page that will be generated, and the path to the file written to.
*/
printProgress?: boolean | undefined;
/**
* Print copyright and version information.
*/
printVersionInfo?: boolean | undefined;
/**
* Do not print any messages or errors.
*/
quiet?: boolean | undefined;
/**
* Specifies the X resolution, in pixels per inch of
* image files (or rasterized regions in vector output). The default is 150 PPI.
*/
resolutionXAxis?: number | undefined;
/**
* Specifies the X and Y resolution, in pixels per
* inch of image files (or rasterized regions in vector output). The default is 150 PPI.
*/
resolutionXYAxis?: number | undefined;
/**
* Specifies the Y resolution, in pixels per inch of
* image files (or rasterized regions in vector output). The default is 150 PPI.
*/
resolutionYAxis?: number | undefined;
/**
* Scales the long side of each page (width for landscape
* pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will
* be determined by the aspect ratio of the page.
*/
scalePageTo?: number | undefined;
/**
* Scales each page horizontally to fit in scale-to-x
* pixels. If scale-to-y is set to -1, the vertical size will determined by the aspect ratio of
* the page.
*/
scalePageToXAxis?: number | undefined;
/**
* Scales each page vertically to fit in scale-to-y
* pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio of
* the page.
*/
scalePageToYAxis?: number | undefined;
/**
* Specify single character separator between name and page number.
*/
separator?: string | undefined;
/**
* Writes only the first page and does not add digits.
*/
singleFile?: boolean | undefined;
/**
* Specifies the thin line mode. This defaults to `none`.
*/
thinLineMode?: "none" | "shape" | "solid" | undefined;
/**
* Set TIFF compression.
*/
tiffCompression?: "none" | "deflate" | "jpeg" | "lzw" | "packbits" | undefined;
/**
* Generate TIFF file instead a PPM file.
*/
tiffFile?: boolean | undefined;
/**
* Specify the user password for the PDF file.
*/
userPassword?: string | undefined;
};
export type PdfToPsOptions = {
/**
* Enable anti-aliasing on rasterization, accepts `no` or `yes`.
*/
antialias?: "no" | "yes" | undefined;
/**
* Write binary data in Level 1 PostScript. By default,
* pdftops writes hex-encoded data in Level 1 PostScript. Binary data is non-standard in Level 1
* PostScript but reduces the file size and can be useful when Level 1 PostScript is required
* only for its restricted use of PostScript operators.
*/
binary?: boolean | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the DefaultCMYK color space to the ICC profile stored in the display profile file passed.
*/
defaultCmykProfile?: string | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the DefaultGray color space to the ICC profile stored in the display profile file passed.
*/
defaultGrayProfile?: string | undefined;
/**
* If Poppler is compiled with colour management support, this option
* sets the DefaultRGB color space to the ICC profile stored in the display profile file passed.
*/
defaultRgbProfile?: string | undefined;
/**
* Set the Duplex pagedevice entry in the PostScript file.
* This tells duplex-capable printers to enable duplexing.
*/
duplex?: boolean | undefined;
/**
* Generate an EPS file. An EPS file contains a single image,
* so if you use this option with a multi-page PDF file, you must use `options.firstPageToConvert` and
* `options.lastPageToConvert` to specify a single page.
* The page size options (originalPageSizes, paperSize, paperWidth, paperHeight) can not be used
* with this option.
*/
epsFile?: boolean | undefined;
/**
* Expand PDF pages smaller than the paper to fill the
* paper. By default, these pages are not scaled.
*/
fillPage?: boolean | undefined;
/**
* Specifies the first page to convert.
*/
firstPageToConvert?: number | undefined;
/**
* Generate PostScript form which can be imported by software
* that understands forms.
* A form contains a single page, so if you use this option with a multi-page PDF file,
* you must use `options.firstPageToConvert` and `options.lastPageToConvert` to specify a single page.
* The `options.level1` option cannot be used with `options.form`.
* No more than one of the mode options (`options.epsFile`, `options.form`) may be given.
*/
form?: number | undefined;
/**
* Specifies the last page to convert.
*/
lastPageToConvert?: number | undefined;
/**
* Generate Level 1 PostScript. The resulting PostScript
* files will be significantly larger (if they contain images), but will print on Level 1 printers.
* This also converts all images to black and white.
*/
level1?: boolean | undefined;
/**
* Generate Level 1 separable PostScript.
* All colors are converted to CMYK. Images are written with separate stream data for the four components.
*/
level1Sep?: boolean | undefined;
/**
* Generate Level 2 PostScript.
* Level 2 supports color images and image compression. This is the default setting.
*/
level2?: boolean | undefined;
/**
* Generate Level 2 separable PostScript. All colors are
* converted to CMYK. The PostScript separation convention operators are used to handle custom (spot) colors.
*/
level2Sep?: boolean | undefined;
/**
* Generate Level 3 PostScript.
* This enables all Level 2 features plus CID font embedding.
*/
level3?: boolean | undefined;
/**
* Generate Level 3 separable PostScript.
* The separation handling is the same as for `options.level2Sep`.
*/
level3Sep?: boolean | undefined;
/**
* By default, PDF pages smaller than the paper
* (after any scaling) are centered on the paper. This option causes them to be aligned to
* the lower-left corner of the paper instead.
*/
noCenter?: boolean | undefined;
/**
* By default, printing output is cropped to the CropBox
* specified in the PDF file. This option disables cropping.
*/
noCrop?: boolean | undefined;
/**
* By default, any CID PostScript fonts which are
* embedded in the PDF file are copied into the PostScript file. This option disables that embedding.
* No attempt is made to substitute for non-embedded CID PostScript fonts.
*/
noEmbedCIDFonts?: boolean | undefined;
/**
* By default, any CID TrueType fonts which are
* embedded in the PDF file are copied into the PostScript file. This option disables that embedding.
* No attempt is made to substitute for non-embedded CID TrueType fonts.
*/
noEmbedCIDTrueTypeFonts?: boolean | undefined;
/**
* By default, any TrueType fonts which are embedded
* in the PDF file are copied into the PostScript file. This option causes pdfToPs to substitute base fonts instead.
* Embedded fonts make PostScript files larger, but may be necessary for readable output.
* Also, some PostScript interpreters do not have TrueType rasterizers.
*/
noEmbedTrueTypeFonts?: boolean | undefined;
/**
* By default, any Type 1 fonts which are embedded in the PDF file
* are copied into the PostScript file. This option causes pdfToPs to substitute base fonts instead.
* Embedded fonts make PostScript files larger, but may be necessary for readable output.
*/
noEmbedType1Fonts?: boolean | undefined;
/**
* Do not scale PDF pages which are larger than the paper.
* By default, pages larger than the paper are shrunk to fit.
*/
noShrink?: boolean | undefined;
/**
* Generate OPI comments for all images and forms which have OPI information.
*/
opi?: boolean | undefined;
/**
* By default, bitmap images in the PDF pass through to the
* output PostScript in their original color space, which produces predictable results.
* This option converts RGB and CMYK images into Gray images if every pixel of the image has equal components.
* This can fix problems when doing color separations of PDFs that contain embedded black and
* white images encoded as RGB.
*/
optimizecolorspace?: boolean | undefined;
/**
* Set the paper size of each page to match
* the size specified in the PDF file.
*/
originalPageSizes?: boolean | undefined;
/**
* Enable overprinting.
*/
overprint?: boolean | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Set the paper height, in points.
*/
paperHeight?: number | undefined;
/**
* Set the paper size to one of `A3`, `A4`,
* `legal`, or `letter`. This can also be set to `match`, which will set the paper size
* of each page to match the size specified in the PDF file. If none of the paperSize,
* paperWidth, or paperHeight options are specified the default is to match the paper size.
*/
paperSize?: "A3" | "A4" | "legal" | "letter" | "match" | undefined;
/**
* Set the paper width, in points.
*/
paperWidth?: number | undefined;
/**
* By default, references to non-embedded 8-bit fonts
* in the PDF file are substituted with the closest `Helvetica`, `Times-Roman`, or `Courier` font.
* This option passes references to non-embedded fonts through to the PostScript file.
*/
passfonts?: boolean | undefined;
/**
* Preload images and forms.
*/
preload?: boolean | undefined;
/**
* Print copyright and version information.
*/
printVersionInfo?: boolean | undefined;
/**
* Sets the process color format as it is used
* during rasterization and transparency reduction.
*
* The default depends on the other settings: For `options.level1` the default is MONO8; for `options.level1Sep`,
* `options.level2Sep`, `options.level3Sep`, or `options.overprint` the default is CMYK8; in all other
* cases RGB8 is the default.
* If `option.processColorProfile` is set then `options.processColorFormat` is inferred from the specified ICC profile.
*/
processColorFormat?: "CMYK8" | "MONO8" | "RGB8" | undefined;
/**
* Sets the ICC profile that is assumed during
* rasterization and transparency reduction.
*/
processColorProfile?: string | undefined;
/**
* Do not print any messages or errors.
*/
quiet?: boolean | undefined;
/**
* By default, pdfToPs rasterizes pages as needed,
* for example, if they contain transparencies. To force rasterization, set `rasterize` to `always`.
* Use this to eliminate fonts.
* To prevent rasterization, set `rasterize` to `never`.
* This may produce files that display incorrectly.
*/
rasterize?: "always" | "never" | "whenneeded" | undefined;
/**
* Specifies the X and Y resolution, in pixels per
* inch of image files (or rasterized regions in vector output). The default is 300 PPI.
*/
resolutionXYAxis?: number | undefined;
/**
* User password (for encrypted files).
*/
userPassword?: string | undefined;
};
export type PdfToTextOptions = {
/**
* Generate an XHTML file containing bounding
* box information for each word in the file.
*/
boundingBoxXhtml?: boolean | undefined;
/**
* Generate an XHTML file containing
* bounding box information for each block, line, and word in the file.
*/
boundingBoxXhtmlLayout?: boolean | undefined;
/**
* Use the crop box rather than the media box with
* `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout`.
*/
cropBox?: boolean | undefined;
/**
* Specifies the height of crop area in pixels
* (image output) or points (vector output).
*/
cropHeight?: number | undefined;
/**
* Specifies the width of crop area in pixels
* (image output) or points (vector output).
*/
cropWidth?: number | undefined;
/**
* Specifies the x-coordinate of the crop area top left
* corner in pixels (image output) or points (vector output).
*/
cropXAxis?: number | undefined;
/**
* Specifies the y-coordinate of the crop area top left
* corner in pixels (image output) or points (vector output).
*/
cropYAxis?: number | undefined;
/**
* Sets the end-of-line convention to use for
* text output: dos; mac; unix.
*/
eolConvention?: "dos" | "mac" | "unix" | undefined;
/**
* Specifies the first page to convert.
*/
firstPageToConvert?: number | undefined;
/**
* Assume fixed-pitch (or tabular) text, with the
* specified character width (in points). This forces physical layout mode.
*/
fixedWidthLayout?: number | undefined;
/**
* Generate simple HTML file, including the
* meta information. This simply wraps the text in `<pre>` and `</pre>` and prepends the meta headers.
*/
generateHtmlMetaFile?: boolean | undefined;
/**
* Generate a TSV file containing the bounding box
* information for each block, line, and word in the file.
*/
generateTsvFile?: boolean | undefined;
/**
* Specifies the last page to convert.
*/
lastPageToConvert?: number | undefined;
/**
* List the available encodings.
*/
listEncodingOptions?: boolean | undefined;
/**
* Maintain (as best as possible) the original physical
* layout of the text. The default is to undo physical layout (columns, hyphenation, etc.) and
* output the text in reading order.
*/
maintainLayout?: boolean | undefined;
/**
* Discard diagonal text.
*/
noDiagonalText?: boolean | undefined;
/**
* Do not insert page breaks (form feed characters)
* between pages.
*/
noPageBreaks?: boolean | undefined;
/**
* Sets the encoding to use for text output.
* This defaults to `UTF-8`.
*/
outputEncoding?: string | undefined;
/**
* Owner password (for encrypted files).
*/
ownerPassword?: string | undefined;
/**
* Print copyright and version information.
*/
printVersionInfo?: boolean | undefined;
/**
* Do not print any messages or errors.
*/
quiet?: boolean | undefined;
/**
* Keep the text in content stream order. This is a
* hack which often undoes column formatting, etc. Use of raw mode is no longer recommended.
*/
rawLayout?: boolean | undefined;
/**
* User password (for encrypted files).
*/
userPassword?: string | undefined;
};
export type PdfUniteOptions = {
/**
* Print copyright and version information.
*/
printVersionInfo?: boolean | undefined;
};
export type PopplerExtraOptions = {
/**
* An `AbortSignal` that can be used to cancel the operation.
*/
signal?: AbortSignal | undefined;
};
export class Poppler {
/**
* @param {string} [binPath] - Path of poppler-utils binaries.
* If not provided, the constructor will attempt to find the Poppler `pdfinfo` binary
* in the PATH environment variable and use that as the path for all binaries.
* For `win32` the binaries are bundled with the package and will be used
* if a local installation is not found.
* @throws {Error} If the Poppler binaries cannot be found.
*/
constructor(binPath?: string);
/**
* @description Returns the path of the Poppler binaries.
* @returns {string} Path of Poppler binaries.
*/
get path(): string;
/**
* @author Frazer Smith
* @description Embeds files (attachments) into a PDF file.
* @param {string} file - Filepath of the PDF file to read.
* @param {string} fileToAttach - Filepath of the attachment to be embedded into the PDF file.
* @param {string} outputFile - Filepath of the file to output the results to.
* @param {PdfAttachOptions} [options] - Options to pass to pdfattach binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfAttach(file: string, fileToAttach: string, outputFile: string, options?: PdfAttachOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Lists or extracts embedded files (attachments) from a PDF file.
* @param {string} file - Filepath of the PDF file to read.
* @param {PdfDetachOptions} [options] - Options to pass to pdfdetach binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfDetach(file: string, options?: PdfDetachOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Lists the fonts used in a PDF file along with various information for each font.
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {PdfFontsOptions} [options] - Options to pass to pdffonts binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfFonts(file: (Buffer | string), options?: PdfFontsOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files.
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {string} [outputPrefix] - Filename prefix of output files.
* @param {PdfImagesOptions} [options] - Options to pass to pdfimages binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfImages(file: (Buffer | string), outputPrefix?: string, options?: PdfImagesOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Prints the contents of the `Info` dictionary from a PDF file.
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {PdfInfoOptions} [options] - Options to pass to pdfinfo binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<Record<string, string>|string>} A promise that resolves with a stdout string or JSON object if
* `options.printAsJson` is `true`, or rejects with an `Error` object.
*/
pdfInfo(file: (Buffer | string), options?: PdfInfoOptions, extras?: PopplerExtraOptions): Promise<Record<string, string> | string>;
/**
* @author Frazer Smith
* @description Extracts single pages from a PDF file,
* and writes one PDF file for each page to outputPattern.
* This will not work if the file is encrypted.
* @param {string} file - Filepath of the PDF file to read.
* @param {string} outputPattern - Should contain %d (or any variant respecting printf format),
* since %d is replaced by the page number.
* As an example, `sample-%d.pdf` will produce `sample-1.pdf` for a single page document.
* @param {PdfSeparateOptions} [options] - Options to pass to pdfseparate binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfSeparate(file: string, outputPattern: string, options?: PdfSeparateOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Converts a PDF file to EPS/JPEG/PDF/PNG/PS/SVG/TIFF.
* @param {Buffer|string} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {string} [outputFile] - Filepath of the file to output the results to.
*
* If `undefined` then will write output to stdout. Using stdout is not valid with image formats
* (jpeg, png, and tiff) unless `options.singleFile` is set to `true`.
* Encoding is set to `binary` if used with `options.singleFile` or `options.pdfFile`.
*
* If not set then the output filename will be derived from the PDF file name.
* @param {PdfToCairoOptions} [options] - Options to pass to pdftocairo binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfToCairo(file: Buffer | string, outputFile?: string, options?: PdfToCairoOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Converts a PDF file to HTML.
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {string} [outputFile] - Filepath of the file to output the results to.
* If `undefined` then Poppler will use the directory and name of the original file
* and create a new file, with `-html` appended to the end of the filename.
*
* Required if `file` is a Buffer.
* @param {PdfToHtmlOptions} [options] - Options to pass to pdftohtml binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfToHtml(file: (Buffer | string), outputFile?: string, options?: PdfToHtmlOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Converts a PDF file to colour image files in Portable Pixmap (PPM) format,
* grayscale image files in Portable Graymap (PGM) format, or monochrome image files
* in Portable Bitmap (PBM) format.
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {string} outputPath - Filepath to output the results to.
* @param {PdfToPpmOptions} [options] - Options to pass to pdftoppm binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfToPpm(file: (Buffer | string), outputPath: string, options?: PdfToPpmOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Converts a PDF file to PostScript (PS).
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {string} [outputFile] - Filepath of the file to output the results to.
* If `undefined` then will write output to stdout.
* @param {PdfToPsOptions} [options] - Options to pass to pdftops binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfToPs(file: (Buffer | string), outputFile?: string, options?: PdfToPsOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Converts a PDF file to TXT.
* @param {(Buffer|string)} file - PDF file as Buffer, or filepath of the PDF file to read.
* @param {string} [outputFile] - Filepath of the file to output the results to.
* If `undefined` then will write output to stdout.
* @param {PdfToTextOptions} [options] - Options to pass to pdftotext binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfToText(file: (Buffer | string), outputFile?: string, options?: PdfToTextOptions, extras?: PopplerExtraOptions): Promise<string>;
/**
* @author Frazer Smith
* @description Merges several PDF files in order of their occurrence in the files array to
* one PDF result file.
* @param {string[]} files - Filepaths of the PDF files to merge.
* An entire directory of PDF files can be merged like so: `path/to/directory/*.pdf`.
* @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
* @param {PdfUniteOptions} [options] - Options to pass to pdfunite binary.
* @param {PopplerExtraOptions} [extras] - Extra options.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
pdfUnite(files: string[], outputFile: string, options?: PdfUniteOptions, extras?: PopplerExtraOptions): Promise<string>;
#private;
}