diff --git a/API.md b/API.md index 02c8f376..c73a3614 100644 --- a/API.md +++ b/API.md @@ -24,7 +24,7 @@ version of binary.

* [.pdfAttach(file, fileToAttach, outputFile, [options])](#Poppler+pdfAttach) ⇒ Promise.<(string\|Error)> * [.pdfDetach(file, [options])](#Poppler+pdfDetach) ⇒ Promise.<(string\|Error)> * [.pdfFonts(file, [options])](#Poppler+pdfFonts) ⇒ Promise.<(string\|Error)> - * [.pdfImages(file, outputPrefix, [options])](#Poppler+pdfImages) ⇒ Promise.<(string\|Error)> + * [.pdfImages(file, [outputPrefix], [options])](#Poppler+pdfImages) ⇒ Promise.<(string\|Error)> * [.pdfInfo(file, [options])](#Poppler+pdfInfo) ⇒ Promise.<(string\|Error)> * [.pdfSeparate(file, outputPattern, [options])](#Poppler+pdfSeparate) ⇒ Promise.<(string\|Error)> * [.pdfToCairo(file, [outputFile], [options])](#Poppler+pdfToCairo) ⇒ Promise.<(string\|Error)> @@ -94,7 +94,7 @@ Lists the fonts used in a PDF file along with various information for each font. | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | [options] | object | Object containing options to pass to binary. | | [options.firstPageToExamine] | number | Specifies the first page to examine. | | [options.lastPageToExamine] | number | Specifies the last page to examine. | @@ -105,7 +105,7 @@ Lists the fonts used in a PDF file along with various information for each font. -### poppler.pdfImages(file, outputPrefix, [options]) ⇒ Promise.<(string\|Error)> +### poppler.pdfImages(file, [outputPrefix], [options]) ⇒ Promise.<(string\|Error)> Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files. **Kind**: instance method of [Poppler](#Poppler) @@ -114,8 +114,8 @@ Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 fi | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | -| outputPrefix | string | Filename prefix of output files. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | +| [outputPrefix] | string | Filename prefix of output files. | | [options] | object | Object containing options to pass to binary. | | [options.allFiles] | boolean | 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. | | [options.ccittFile] | boolean | Generate CCITT images as CCITT files. | @@ -142,7 +142,7 @@ Prints the contents of the `Info` dictionary from a PDF file. | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | [options] | object | Object containing options to pass to binary. | | [options.firstPageToConvert] | number | First page to print. | | [options.lastPageToConvert] | number | Last page to print. | @@ -191,7 +191,7 @@ Converts a PDF file to PNG/JPEG/TIFF/PDF/PS/EPS/SVG. | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | [outputFile] | string | 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 unless `options.singleFile` is set to `true`. If not set then the output filename will be derived from the PDF file name. | | [options] | object | Object containing options to pass to binary. | | [options.antialias] | 'default' \| 'none' \| 'gray' \| 'subpixel' \| 'fast' \| 'good' \| 'best' | Set the cairo antialias option used for text and drawing in image files (or rasterized regions in vector output). | @@ -254,7 +254,7 @@ and append `-html` to the end of the filename. | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | [options] | object | Object containing options to pass to binary. | | [options.complexOutput] | boolean | Generate complex output. | | [options.dataUrls] | boolean | Use data URLs instead of external images in HTML. | @@ -293,7 +293,7 @@ in Portable Bitmap (PBM) format. | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | outputPath | string | Filepath to output the results to. | | [options] | object | Object containing options to pass to binary. | | [options.antialiasFonts] | 'yes' \| 'no' | Enable or disable font anti-aliasing. This defaults to `yes`. | @@ -347,7 +347,7 @@ Converts a PDF file to PostScript (PS). | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | [outputFile] | string | Filepath of the file to output the results to. If `undefined` then will write output to stdout. | | [options] | object | Object containing options to pass to binary. | | [options.antialias] | 'yes' \| 'no' | Enable anti-aliasing on rasterization, accepts `yes` or `no`. | @@ -403,7 +403,7 @@ Converts a PDF file to TXT. | Param | Type | Description | | --- | --- | --- | -| file | string | Filepath of the PDF file to read. | +| file | Buffer \| string | PDF file as Buffer, or filepath of the PDF file to read. | | [outputFile] | string | Filepath of the file to output the results to. If `undefined` then will write output to stdout. | | [options] | object | Object containing options to pass to binary. | | [options.boundingBoxXhtml] | boolean | Generate an XHTML file containing bounding box information for each word in the file. | diff --git a/package.json b/package.json index f2dadb0e..29838690 100644 --- a/package.json +++ b/package.json @@ -63,21 +63,21 @@ "testTimeout": 10000 }, "devDependencies": { - "@commitlint/cli": "^12.0.1", - "@commitlint/config-conventional": "^12.0.1", - "eslint": "^7.22.0", + "@commitlint/cli": "^12.1.1", + "@commitlint/config-conventional": "^12.1.1", + "eslint": "^7.24.0", "eslint-config-airbnb-base": "^14.2.1", - "eslint-config-prettier": "^8.1.0", + "eslint-config-prettier": "^8.2.0", "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jest": "^24.3.2", + "eslint-plugin-jest": "^24.3.5", "eslint-plugin-jsdoc": "^32.3.0", "eslint-plugin-promise": "^5.1.0", "eslint-plugin-security": "^1.4.0", "glob": "^7.1.6", "husky": "^6.0.0", "jest": "^26.6.3", - "jsdoc-to-markdown": "^7.0.0", + "jsdoc-to-markdown": "^7.0.1", "prettier": "2.2.1", - "typescript": "^4.2.3" + "typescript": "^4.2.4" } } diff --git a/src/index.d.ts b/src/index.d.ts index 80a7062a..2184e224 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -57,7 +57,7 @@ export class Poppler { * @author Frazer Smith * @description Lists the fonts used in a PDF file along with various information for each font. * - * @param {string} file - Filepath of the PDF file to read. + * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read. * @param {object=} options - Object containing options to pass to binary. * @param {number=} options.firstPageToExamine - Specifies the first page to examine. * @param {number=} options.lastPageToExamine - Specifies the last page to examine. @@ -69,15 +69,15 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfFonts( - file: string, + file: Buffer | string, options?: object | undefined ): Promise; /** * @author Frazer Smith * @description Saves images from a PDF file as PPM, PBM, PNG, TIFF, JPEG, JPEG2000, or JBIG2 files. * - * @param {string} file - Filepath of the PDF file to read. - * @param {string} outputPrefix - Filename prefix of output 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 {object=} options - Object containing options to pass to binary. * @param {boolean=} options.allFiles - 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. @@ -98,15 +98,15 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfImages( - file: string, - outputPrefix: string, + file: Buffer | string, + outputPrefix?: string | undefined, options?: object | undefined ): Promise; /** * @author Frazer Smith * @description Prints the contents of the `Info` dictionary from a PDF file. * - * @param {string} file - Filepath of the PDF file to read. + * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read. * @param {object=} options - Object containing options to pass to binary. * @param {number=} options.firstPageToConvert - First page to print. * @param {number=} options.lastPageToConvert - Last page to print. @@ -135,7 +135,7 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfInfo( - file: string, + file: Buffer | string, options?: object | undefined ): Promise; /** @@ -165,7 +165,7 @@ export class Poppler { * @author Frazer Smith * @description Converts a PDF file to PNG/JPEG/TIFF/PDF/PS/EPS/SVG. * - * @param {string} file - Filepath of the PDF file to read. + * @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 @@ -266,7 +266,7 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfToCairo( - file: string, + file: Buffer | string, outputFile?: string | undefined, options?: object | undefined ): Promise; @@ -276,7 +276,7 @@ export class Poppler { * Poppler will use the directory and name of the original file * and append `-html` to the end of the filename. * - * @param {string} file - Filepath of the PDF file to read. + * @param {Buffer| string} file - PDF file as Buffer, or filepath of the PDF file to read. * @param {object=} options - Object containing options to pass to binary. * @param {boolean=} options.complexOutput - Generate complex output. * @param {boolean=} options.dataUrls - Use data URLs instead of external images in HTML. @@ -309,7 +309,7 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfToHtml( - file: string, + file: Buffer | string, options?: object | undefined ): Promise; /** @@ -318,7 +318,7 @@ export class Poppler { * grayscale image files in Portable Graymap (PGM) format, or monochrome image files * in Portable Bitmap (PBM) format. * - * @param {string} file - Filepath of the PDF file to read. + * @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 {object=} options - Object containing options to pass to binary. * @param {('yes'|'no')=} options.antialiasFonts - Enable or disable font anti-aliasing. @@ -388,7 +388,7 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfToPpm( - file: string, + file: Buffer | string, outputPath: string, options?: object | undefined ): Promise; @@ -396,7 +396,7 @@ export class Poppler { * @author Frazer Smith * @description Converts a PDF file to PostScript (PS). * - * @param {string} file - Filepath of the PDF file to read. + * @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 {object=} options - Object containing options to pass to binary. @@ -503,7 +503,7 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfToPs( - file: string, + file: Buffer | string, outputFile?: string | undefined, options?: object | undefined ): Promise; @@ -511,7 +511,7 @@ export class Poppler { * @author Frazer Smith * @description Converts a PDF file to TXT. * - * @param {string} file - Filepath of the PDF file to read. + * @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 {object=} options - Object containing options to pass to binary. @@ -555,7 +555,7 @@ export class Poppler { * @returns {Promise} Promise of stdout string on resolve, or Error object on rejection. */ pdfToText( - file: string, + file: Buffer | string, outputFile?: string | undefined, options?: object | undefined ): Promise;