diff --git a/.eslintrc.js b/.eslintrc.js index 4e168757..9a8de79e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,8 +11,7 @@ module.exports = { "plugin:jsdoc/recommended", "plugin:promise/recommended", "plugin:regexp/recommended", - "plugin:security/recommended", - "plugin:security-node/recommended", + "plugin:security/recommended-legacy", "prettier", ], overrides: [ @@ -40,14 +39,7 @@ module.exports = { // Explicitly tell ESLint to parse JavaScript as CommonJS, as airbnb-base sets this to "modules" for ECMAScript sourceType: "script", }, - plugins: [ - "import", - "jsdoc", - "promise", - "regexp", - "security", - "security-node", - ], + plugins: ["import", "jsdoc", "promise", "regexp", "security"], root: true, rules: { "@eslint-community/eslint-comments/disable-enable-pair": "off", diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index daaa63d8..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: Fdawgs diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 7ab4aa67..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: 🐛 Bug Report -description: File a bug report and help us improve -labels: [bug] - -body: - - type: markdown - attributes: - value: | - Thanks for filing a bug report, any help is greatly appreciated! - - - type: checkboxes - id: prerequisites - attributes: - label: Prerequisites - options: - - label: I have written a descriptive issue title - required: true - - label: | - I have searched existing issues to ensure it has not already been reported - required: true - - label: | - I agree to follow the [Code of Conduct](../../CODE_OF_CONDUCT.md) that this project adheres to - required: true - - - type: input - id: version - attributes: - label: API/app/plugin version - placeholder: 1.x.x - - - type: input - id: node-version - attributes: - label: Node.js version - placeholder: 18.x - validations: - required: true - - - type: dropdown - id: os - attributes: - label: Operating system - options: - - Linux - - macOS - - Windows - validations: - required: true - - - type: input - id: os-version - attributes: - label: Operating system version (i.e. 20.04, 11.3, 10) - validations: - required: true - - - type: textarea - id: description - attributes: - label: Description - description: A clear and concise description of what the bug is. - validations: - required: true - - - type: textarea - id: steps-to-reproduce - attributes: - label: Steps to Reproduce - description: | - List of steps, sample code, or a link to code or a project that reproduces the behaviour. - Make sure you place a stack trace inside a [code (```) block](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) to avoid linking unrelated issues. - validations: - required: true - - - type: textarea - id: expected-behaviour - attributes: - label: Expected Behaviour - description: A clear and concise description of what you expected to happen. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index 617b490d..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: 🚀 Feature Request -description: Submit a proposal for a new feature -labels: [feature] - -body: - - type: markdown - attributes: - value: | - Thanks for making a feature request, new ideas are greatly appreciated! - - - type: checkboxes - id: prerequisites - attributes: - label: Prerequisites - options: - - label: I have written a descriptive title - required: true - - label: | - I have searched existing feature requests to ensure it has not already been proposed - required: true - - label: | - I agree to follow the [Code of Conduct](../../CODE_OF_CONDUCT.md) that this project adheres to - required: true - - - type: textarea - id: description - attributes: - label: Description - description: A clear and concise description of what the feature is, and what it would solve. - validations: - required: true diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md deleted file mode 100644 index 70b31ef3..00000000 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ /dev/null @@ -1,15 +0,0 @@ - - -#### Checklist - -- [ ] Run `npm test` -- [ ] Documentation has been updated and adheres to the style described in [CONTRIBUTING.md](https://github.com/Fdawgs/node-poppler/blob/main/CONTRIBUTING.md#documentation-style) -- [ ] Commit message adheres to the [Conventional commits](https://conventionalcommits.org/en/v1.0.0/) style, following the [@commitlint/config-conventional config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 150ee332..e61c010a 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -24,25 +24,26 @@ jobs: uses: actions/github-script@v7 with: script: | - const fs = require('fs'); + const { writeFile } = require("node:fs/promises"); + const { owner, repo } = context.repo; const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, + owner, + repo, run_id: ${{ github.event.workflow_run.id }}, }); - const matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == 'pr'; - })[0]; + const matchArtifact = artifacts.data.artifacts.find( + (artifact) => artifact.name == "pr" + ); const download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, + owner, + repo, artifact_id: matchArtifact.id, - archive_format: 'zip', + archive_format: "zip", }); - fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); + await writeFile("${{github.workspace}}/pr.zip", Buffer.from(download.data)); - name: Unzip artifact run: unzip pr.zip @@ -52,12 +53,14 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const fs = require('fs'); - const pull_number = Number(fs.readFileSync('./NR')); + const { readFile } = require("node:fs/promises"); + const { owner, repo } = context.repo; + + const pull_number = Number(await readFile("./NR", "utf8")); await github.rest.pulls.merge({ merge_method: "squash", - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull_number, + owner, + repo, + pull_number, }); diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index da2b62f6..0d78c7e5 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,15 +10,15 @@ on: # Allows this workflow to be run manually from the Actions tab workflow_dispatch: -permissions: - contents: write - id-token: write - pull-requests: write - jobs: release: name: Create/Update Release Pull Request runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} steps: - name: Release Please id: release @@ -29,26 +29,71 @@ jobs: release-type: node package-name: node-poppler + publish-npm: + name: Publish to NPM + needs: release + if: needs.release.outputs.release_created == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: - name: Check out repo - if: steps.release.outputs.release_created uses: actions/checkout@v4 with: persist-credentials: false - name: Setup Node - if: steps.release.outputs.release_created uses: actions/setup-node@v4 with: node-version: lts/* - registry-url: https://registry.npmjs.org/ + registry-url: https://registry.npmjs.org - name: Publish to NPM - if: steps.release.outputs.release_created env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # Build docs and TS definitions and remove dev values from package.json + # Build docs and TS definitions, and remove dev values + # from package.json before publishing to reduce package size + run: | + npm i --ignore-scripts + npm run build + npm pkg delete commitlint devDependencies jest scripts + npm publish --access public --ignore-scripts --provenance + + publish-ghp: + name: Publish to GitHub Packages + needs: release + if: needs.release.outputs.release_created == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + packages: write + steps: + - name: Check out repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: lts/* + registry-url: https://npm.pkg.github.com + scope: "@fdawgs" + + - name: Scope package + run: | + pkgName=$(npm pkg get name | tr -d '"') + npm pkg set name="@fdawgs/$pkgName" + + - name: Publish to GitHub Packages + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Build docs and TS definitions, and remove dev values + # from package.json before publishing to reduce package size run: | npm i --ignore-scripts npm run build npm pkg delete commitlint devDependencies jest scripts - npm publish --ignore-scripts --provenance + npm publish --access public --ignore-scripts --provenance diff --git a/.husky/pre-commit b/.husky/pre-commit index a170e009..c613291a 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npm run lint:prettier && npm run lint:licenses && npm test +npm run lint:licenses && npm test diff --git a/.prettierignore b/.prettierignore index 06b9e392..7e896f60 100644 --- a/.prettierignore +++ b/.prettierignore @@ -139,6 +139,7 @@ dist package.json API.md CHANGELOG.md +/types/index.d.ts # lock files bun.lockb diff --git a/.vscode/settings.json b/.vscode/settings.json index 906f3b3f..4ac790be 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,6 @@ }, "javascript.updateImportsOnFileMove.enabled": "always", "npm.packageManager": "npm", + "prettier.prettierPath": "./node_modules/prettier", "redhat.telemetry.enabled": false } diff --git a/API.md b/API.md index c1d8a372..50ddddbb 100644 --- a/API.md +++ b/API.md @@ -85,7 +85,7 @@ Lists the fonts used in a PDF file along with various information for each font. | [options.listSubstitutes] | boolean | List the substitute fonts that poppler will use for non-embedded fonts. | | [options.ownerPassword] | string | Owner password (for encrypted files). | | [options.printVersionInfo] | boolean | Print copyright and version info. | -| [options.userPassword] | string | User password (for encrypted files). * | +| [options.userPassword] | string | User password (for encrypted files). | @@ -260,7 +260,7 @@ Converts a PDF file to HTML. | [options.ownerPassword] | string | Owner password (for encrypted files). | | [options.printVersionInfo] | boolean | Print copyright and version info. | | [options.quiet] | boolean | Do not print any messages or errors. | -| [options.singlePage] | boolean | generate single HTML that includes all pages. | +| [options.singlePage] | boolean | Generate single HTML that includes all pages. | | [options.stdout] | boolean | Use standard output. | | [options.userPassword] | string | User password (for encrypted files). | | [options.wordBreakThreshold] | number | 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. | @@ -395,7 +395,7 @@ Converts a PDF file to TXT. | [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. | | [options.boundingBoxXhtmlLayout] | boolean | Generate an XHTML file containing bounding box information for each block, line, and word in the file. | -| [options.cropBox] | boolean | Use the crop box rather than the media box with `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout` | +| [options.cropBox] | boolean | Use the crop box rather than the media box with `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout`. | | [options.cropHeight] | number | Specifies the height of crop area in pixels (image output) or points (vector output). | | [options.cropWidth] | number | Specifies the width of crop area in pixels (image output) or points (vector output). | | [options.cropXAxis] | number | Specifies the x-coordinate of the crop area top left corner in pixels (image output) or points (vector output). | diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 1ce1f263..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,127 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -- Focusing on what is best not just for us as individuals, but for the overall - community - -Examples of unacceptable behavior include: - -- The use of sexualized language or imagery, and sexual attention or advances of - any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or email address, - without their explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leader responsible for enforcement at frazer.dev@outlook.com. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][mozilla coc]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://contributor-covenant.org/faq][faq]. Translations are available at -[https://contributor-covenant.org/translations][translations]. - -[homepage]: https://contributor-covenant.org -[v2.1]: https://contributor-covenant.org/version/2/1/code_of_conduct.html -[mozilla coc]: https://github.com/mozilla/diversity -[faq]: https://contributor-covenant.org/faq -[translations]: https://contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 1d947332..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,53 +0,0 @@ -# Contributing - -Contributions are welcome and any help that can be offered is greatly appreciated. -Please take a moment to read the entire contributing guide. - -This repository uses the [Feature Branch Workflow](https://atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow), -meaning that development should take place in `feat/` branches, with the `main` branch kept in a stable state. -When you submit pull requests, please make sure to fork from and submit back to `main`. - -Other processes and specifications that are in use in this repository are: - -- [Semantic versioning](https://semver.org/) -- [Conventional commits](https://conventionalcommits.org/en/v1.0.0/) following the [@commitlint/config-conventional config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) -- [Prettier](https://prettier.io/) style guide - -## Getting started - -This repository requires that you have [Node.js](https://nodejs.org) >=14.0.0 installed. - -With that in place, you can fork the repository, clone it, and then run `npm i` to install all dependencies. - -### Development workflow - -After cloning the repository and installing all the dependencies, there are several commands available for local development: - -- `npm run lint` - Lints everything in src directory -- `npm run jest` - Runs Jest over all tests in src directory -- `npm test` - Runs `npm run lint` and `npm run jest` together - -## Documentation style - -Documentation (both in markdown files and inline comments) should be written in **British English** where possible. - -Titles and headings should use sentence-style capitalisation, where only the first letter of a sentence and proper nouns are capitalised. - -## Pull request checklist - -Before submitting a pull request back to the main repository, please make sure you have completed the following steps: - -1. Pull request base branch is set to `main`. All pull requests should be forked from and merged back to `main` -2. Run `npm test` to check the code adheres to the defined ESLint style and that it passes the Jest tests -3. Run `npm run lint:prettier:fix` to run the Prettier code formatter over the code -4. Run `npm run lint:licenses` if adding or updating production dependencies to check they use permissive licenses - -Steps 2. and 4. are automatically run by a pre-commit hook added by [Husky](https://typicode.github.io/husky/#/). - -## Release process - -Before a release, ensure the API docs are regenerated with `npm run build`. - -## Issues - -Please file your issues [here](https://github.com/Fdawgs/node-poppler/issues) and try to provide as much information in the template as possible/relevant. diff --git a/README.md b/README.md index bb6b4324..e19b7e35 100644 --- a/README.md +++ b/README.md @@ -174,8 +174,8 @@ poppler Contributions are welcome, and any help is greatly appreciated! -See [the contributing guide](./CONTRIBUTING.md) for details on how to get started. -Please adhere to this project's [Code of Conduct](./CODE_OF_CONDUCT.md) when contributing. +See [the contributing guide](https://github.com/Fdawgs/.github/blob/main/CONTRIBUTING.md) for details on how to get started. +Please adhere to this project's [Code of Conduct](https://github.com/Fdawgs/.github/blob/main/CODE_OF_CONDUCT.md) when contributing. ## Acknowledgements diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index a4de9d72..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,13 +0,0 @@ -# Security - -## Disclosure policy - -Please email reports about any security-related issues you find to frazer.dev@outlook.com. -Please use a descriptive subject line in your report email, in addition to a reference or link to this repository. -After the initial reply to your report, we will attempt to keep you informed of the progress being made towards a fix. - -In addition, please include the following information along with your report: - -- Your name and affiliation (if any) -- A description of the technical details of the vulnerabilities -- An explanation of who can exploit this vulnerability, and what they gain when doing so diff --git a/package.json b/package.json index b77dd115..fdbf71bb 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,10 @@ "main": "src/index.js", "type": "commonjs", "types": "types/index.d.ts", - "repository": "git+https://github.com/Fdawgs/node-poppler.git", + "repository": { + "type": "git", + "url": "git+https://github.com/Fdawgs/node-poppler.git" + }, "homepage": "https://github.com/Fdawgs/node-poppler", "bugs": { "url": "https://github.com/Fdawgs/node-poppler/issues" @@ -47,15 +50,16 @@ "node": ">=18.0.0" }, "scripts": { - "build": "tsc && jsdoc2md src/index.js > API.md && npm run lint:prettier:fix", + "build": "tsc && jsdoc2md src/index.js > API.md", "jest": "jest", "jest:coverage": "jest --coverage", "lint": "eslint . --cache --ext js,jsx --ignore-path .gitignore", + "lint:fix": "npm run lint -- --fix", "lint:licenses": "node scripts/license-checker.js", "lint:prettier": "prettier . -c -u", "lint:prettier:fix": "prettier . -w -u", "prepare": "husky install", - "test": "npm run lint && npm run jest" + "test": "npm run lint && npm run lint:prettier && npm run jest" }, "commitlint": { "extends": [ @@ -82,28 +86,27 @@ "testTimeout": 60000 }, "devDependencies": { - "@commitlint/cli": "^18.2.0", - "@commitlint/config-conventional": "^18.1.0", + "@commitlint/cli": "^18.5.0", + "@commitlint/config-conventional": "^18.5.0", "@eslint-community/eslint-plugin-eslint-comments": "^4.1.0", - "@types/jest": "^29.5.5", - "eslint": "^8.50.0", + "@types/jest": "^29.5.11", + "eslint": "^8.56.0", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jest": "^27.4.0", - "eslint-plugin-jsdoc": "^46.8.2", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jest": "^27.6.3", + "eslint-plugin-jsdoc": "^48.0.2", "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-regexp": "^2.1.1", - "eslint-plugin-security": "^1.7.1", - "eslint-plugin-security-node": "^1.1.1", - "glob": "^10.3.6", + "eslint-plugin-regexp": "^2.2.0", + "eslint-plugin-security": "^2.1.0", + "glob": "^10.3.10", "husky": "^8.0.3", "jest": "^29.7.0", "jsdoc-to-markdown": "^8.0.0", "license-checker": "^25.0.1", - "prettier": "^3.0.3", + "prettier": "^3.2.4", "spdx-copyleft": "^1.0.0", - "typescript": "^5.2.2" + "typescript": "^5.3.3" }, "dependencies": { "camelcase": "^6.3.0", diff --git a/scripts/license-checker.js b/scripts/license-checker.js index c974f5fa..a36cc25e 100644 --- a/scripts/license-checker.js +++ b/scripts/license-checker.js @@ -57,10 +57,20 @@ async function checkLicenses() { start: joinSafe(__dirname, ".."), }); - const copyLeftLicensesList = Object.keys(licenses).filter((license) => - // @ts-ignore: includes() returns false if undefined is passed - copyLeftLicenses.includes(licenses[license].licenses) - ); + const copyLeftLicensesList = Object.keys(licenses).filter((license) => { + let lic = licenses[license].licenses; + + if (!lic) { + console.error( + `No license found for ${license}. Please check the package.json file.` + ); + process.exit(1); + } + + lic = Array.isArray(lic) ? lic : [lic]; + + return lic.some((l) => copyLeftLicenses.includes(l)); + }); if (copyLeftLicensesList.length > 0) { console.error( diff --git a/tsconfig.json b/tsconfig.json index 4e1a958b..0f34a80c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,12 +4,11 @@ "checkJs": true, "declaration": true, "emitDeclarationOnly": true, - "lib": ["ES2022"], "module": "NodeNext", "moduleResolution": "NodeNext", "outDir": "types", "resolveJsonModule": true, - "target": "ES2022" + "target": "ES2022", }, - "include": ["src/index.js"] + "include": ["src/index.js"], } diff --git a/types/index.d.ts b/types/index.d.ts index e496228c..5f22de60 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,823 +1,769 @@ export default Poppler; export class Poppler { - /** @param {string} [binPath] - Path of poppler-utils binaries. */ - constructor(binPath?: string); - popplerPath: 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 {object} [options] - Object containing options to pass to binary. - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @param {boolean} [options.replace] - Replace embedded file with same name (if it exists). - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfAttach( - file: string, - fileToAttach: string, - outputFile: string, - options?: { - printVersionInfo?: boolean; - replace?: boolean; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {boolean} [options.listEmbedded] - List all of the embedded files in the PDF file. - * File names are converted to the text encoding specified by `options.outputEncoding`. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. - * This defaults to `UTF-8`. - * @param {string} [options.outputPath] - Set the file name used when saving an embedded file with - * the save option enabled, or the directory if `options.saveall` is used. - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @param {boolean} [options.saveAllFiles] - 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`. - * @param {string} [options.saveFile] - 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`. - * @param {number} [options.saveSpecificFile] - 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`. - * @param {string} [options.userPassword] - User password (for encrypted files). - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfDetach( - file: string, - options?: { - listEmbedded?: boolean; - ownerPassword?: string; - outputEncoding?: string; - outputPath?: string; - printVersionInfo?: boolean; - saveAllFiles?: boolean; - saveFile?: string; - saveSpecificFile?: number; - userPassword?: string; - } - ): Promise; - /** - * @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 {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. - * @param {boolean} [options.listSubstitutes] - List the substitute fonts that poppler - * will use for non-embedded fonts. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @param {string} [options.userPassword] - User password (for encrypted files). * - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfFonts( - file: Buffer | string, - options?: { - firstPageToExamine?: number; - lastPageToExamine?: number; - listSubstitutes?: boolean; - ownerPassword?: string; - printVersionInfo?: boolean; - userPassword?: string; - } - ): Promise; - /** - * @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 {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. - * @param {boolean} [options.ccittFile] - Generate CCITT images as CCITT files. - * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. - * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. - * @param {boolean} [options.list] - Instead of writing the images, list the - * images along with various information for each image. - * NOTE: Do not specify the outputPrefix with this option. - * @param {boolean} [options.jbig2File] - Generate JBIG2 images as JBIG2 files. - * @param {boolean} [options.jpeg2000File] - Generate JPEG2000 images at JP2 files. - * @param {boolean} [options.jpegFile] - Generate JPEG images as JPEG files. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {boolean} [options.pngFile] - Change the default output format to PNG. - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @param {boolean} [options.tiffFile] - Change the default output format to TIFF. - * @param {string} [options.userPassword] - Specify the user password for the PDF file. - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfImages( - file: Buffer | string, - outputPrefix?: string, - options?: { - allFiles?: boolean; - ccittFile?: boolean; - firstPageToConvert?: number; - lastPageToConvert?: number; - list?: boolean; - jbig2File?: boolean; - jpeg2000File?: boolean; - jpegFile?: boolean; - ownerPassword?: string; - pngFile?: boolean; - printVersionInfo?: boolean; - tiffFile?: boolean; - userPassword?: string; - } - ): Promise; - /** - * @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 {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. - * @param {boolean} [options.listEncodingOptions] - List the available encodings. - * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. - * This defaults to `UTF-8`. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {boolean} [options.printAsJson] - Print result as a JSON object. - * @param {boolean} [options.printBoundingBoxes] - Prints the page box bounding boxes: - * MediaBox, CropBox, BleedBox, TrimBox, and ArtBox. - * @param {boolean} [options.printDocStruct] - Prints the logical document structure - * of a Tagged-PDF file. - * @param {boolean} [options.printDocStructText] - 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. - * @param {boolean} [options.printIsoDates] - Prints dates in ISO-8601 format (including the time zone). - * @param {boolean} [options.printJS] - Prints all JavaScript in the PDF file. - * @param {boolean} [options.printMetadata] - Prints document-level metadata. (This is the `Metadata` - * stream from the PDF file's Catalog object). - * @param {boolean} [options.printNamedDests] - 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. - * @param {boolean} [options.printRawDates] - Prints the raw (undecoded) date strings, directly from the PDF file. - * @param {boolean} [options.printUrls] - 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. - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @param {string} [options.userPassword] - User password (for encrypted files). - * @returns {Promise} 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?: { - firstPageToConvert?: number; - lastPageToConvert?: number; - listEncodingOptions?: boolean; - outputEncoding?: string; - ownerPassword?: string; - printAsJson?: boolean; - printBoundingBoxes?: boolean; - printDocStruct?: boolean; - printDocStructText?: boolean; - printIsoDates?: boolean; - printJS?: boolean; - printMetadata?: boolean; - printNamedDests?: boolean; - printRawDates?: boolean; - printUrls?: boolean; - printVersionInfo?: boolean; - userPassword?: string; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {number} [options.firstPageToExtract] - Specifies the first page to extract. - * This defaults to page 1. - * @param {number} [options.lastPageToExtract] - Specifies the last page to extract. - * This defaults to the last page of the PDF file. - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfSeparate( - file: string, - outputPattern: string, - options?: { - firstPageToExtract?: number; - lastPageToExtract?: number; - printVersionInfo?: boolean; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {('best'|'default'|'fast'|'good'|'gray'|'none'|'subpixel')} [options.antialias] - Set the cairo - * antialias option used for text and drawing in image files (or rasterized regions in vector output). - * @param {boolean} [options.cropBox] - Uses the crop box rather than media box when - * generating the files (PNG/JPEG/TIFF only). - * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels - * (image output) or points (vector output). - * @param {number} [options.cropSize] - Specifies the size of crop square in pixels - * (image output) or points (vector output). - * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels - * (image output) or points (vector output). - * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left - * corner in pixels (image output) or points (vector output). - * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left - * corner in pixels (image output) or points (vector output). - * @param {boolean} [options.duplex] - Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC - * comment to the PostScript file (PS only). This tells the print manager to enable duplexing. - * @param {boolean} [options.epsFile] - 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. - * @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages. - * @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the - * paper (PS,PDF,SVG only). By default, these pages are not scaled. - * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. - * @param {boolean} [options.grayscaleFile] - Generate grayscale file (PNG, JPEG, and TIFF only). - * @param {string} [options.iccFile] - Use the specified ICC file as the output profile - * (PNG only). The profile will be embedded in the PNG file. - * @param {boolean} [options.jpegFile] - Generate JPEG file(s). - * @param {string} [options.jpegOptions] - When used with `options.jpegFile`, this option can - * be used to control the JPEG compression parameters. It takes a string of the form - * `"=[,=]"`. 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"`. - * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. - * @param {boolean} [options.monochromeFile] - Generate monochrome file (PNG and TIFF only). - * @param {boolean} [options.noCenter] - 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). - * @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox - * specified in the PDF file. This option disables cropping (PS, PDF, SVG only). - * @param {boolean} [options.noShrink] - 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. - * @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages. - * @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match - * the size specified in the PDF file. - * @param {string} [options.ownerPassword] - Specify the owner password for the PDF file. - * Providing this will bypass all security restrictions. - * @param {number} [options.paperHeight] - Set the paper height, in points (PS, PDF, SVG only). - * @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - 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. - * @param {number} [options.paperWidth] - Set the paper width, in points (PS,PDF,SVG only). - * @param {boolean} [options.pdfFile] - Generate PDF file. - * @param {boolean} [options.pngFile] - Generate PNG file(s). - * @param {boolean} [options.printVersionInfo] - Print copyright and version information. - * @param {boolean} [options.printDocStruct] - If the input file contains structural information - * about the document's content, write this information to the output file (PDF only). - * @param {boolean} [options.psFile] - Generate PS file. - * @param {boolean} [options.psLevel2] - Generate Level 2 PostScript (PS only). - * @param {boolean} [options.psLevel3] - Generate Level 3 PostScript (PS only). This enables all - * Level 2 features plus shading patterns and masked images. This is the default setting. - * @param {boolean} [options.quiet] - Do not print any messages or errors. - * @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of - * image files (or rasterized regions in vector output). The default is 150 PPI. - * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per - * inch of image files (or rasterized regions in vector output). The default is 150 PPI. - * @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of - * image files (or rasterized regions in vector output). The default is 150 PPI. - * @param {number} [options.scalePageTo] - 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). - * @param {number} [options.scalePageToXAxis] - 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). - * @param {number} [options.scalePageToYAxis] - 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). - * @param {boolean} [options.singleFile] - Writes only the first page and does not add digits. - * Can only be used with `options.jpegFile`, `options.pngFile`, and `options.tiffFile`. - * @param {boolean} [options.svgFile] - Generate SVG (Scalable Vector Graphics) file. - * @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression. - * @param {boolean} [options.tiffFile] - Generate TIFF file(s). - * @param {boolean} [options.transparentPageColor] - Use a transparent page color - * instead of white (PNG and TIFF only). - * @param {string} [options.userPassword] - Specify the user password for the PDF file. - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfToCairo( - file: Buffer | string, - outputFile?: string, - options?: { - antialias?: - | "best" - | "default" - | "fast" - | "good" - | "gray" - | "none" - | "subpixel"; - cropBox?: boolean; - cropHeight?: number; - cropSize?: number; - cropWidth?: number; - cropXAxis?: number; - cropYAxis?: number; - duplex?: boolean; - epsFile?: boolean; - evenPagesOnly?: boolean; - fillPage?: boolean; - firstPageToConvert?: number; - grayscaleFile?: boolean; - iccFile?: string; - jpegFile?: boolean; - jpegOptions?: string; - lastPageToConvert?: number; - monochromeFile?: boolean; - noCenter?: boolean; - noCrop?: boolean; - noShrink?: boolean; - oddPagesOnly?: boolean; - originalPageSizes?: boolean; - ownerPassword?: string; - paperHeight?: number; - paperSize?: "A3" | "A4" | "legal" | "letter" | "match"; - paperWidth?: number; - pdfFile?: boolean; - pngFile?: boolean; - printVersionInfo?: boolean; - printDocStruct?: boolean; - psFile?: boolean; - psLevel2?: boolean; - psLevel3?: boolean; - quiet?: boolean; - resolutionXAxis?: number; - resolutionXYAxis?: number; - resolutionYAxis?: number; - scalePageTo?: number; - scalePageToXAxis?: number; - scalePageToYAxis?: number; - singleFile?: boolean; - svgFile?: boolean; - tiffCompression?: "deflate" | "jpeg" | "lzw" | "none" | "packbits"; - tiffFile?: boolean; - transparentPageColor?: boolean; - userPassword?: string; - } - ): Promise; - /** - * @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 {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. - * @param {boolean} [options.exchangePdfLinks] - Exchange .pdf links with .html. - * @param {boolean} [options.extractHidden] - Force hidden text extraction. - * @param {number} [options.firstPageToConvert] - First page to print. - * @param {boolean} [options.fontFullName] - Outputs the font name without any substitutions. - * @param {boolean} [options.ignoreImages] - Ignore images. - * @param {('JPG'|'PNG')} [options.imageFormat] - Image file format for Splash output (JPG or PNG). - * If complexOutput is selected, but imageFormat is not specified, PNG will be assumed. - * @param {number} [options.lastPageToConvert] - Last page to print. - * @param {boolean} [options.noDrm] - Override document DRM settings. - * @param {boolean} [options.noFrames] - Generate no frames. Not supported in complex output mode. - * @param {boolean} [options.noMergeParagraph] - Do not merge paragraphs. - * @param {boolean} [options.noRoundedCoordinates] - Do not round coordinates - * (with XML output only). - * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. - * This defaults to `UTF-8`. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {boolean} [options.printVersionInfo] - Print copyright and version info. - * @param {boolean} [options.quiet] - Do not print any messages or errors. - * @param {boolean} [options.singlePage] - generate single HTML that includes all pages. - * @param {boolean} [options.stdout] - Use standard output. - * @param {string} [options.userPassword] - User password (for encrypted files). - * @param {number} [options.wordBreakThreshold] - 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. - * @param {boolean} [options.xmlOutput] - Output for XML post-processing. - * @param {number} [options.zoom] - Zoom the PDF document (default 1.5). - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfToHtml( - file: Buffer | string, - outputFile?: string, - options?: { - complexOutput?: boolean; - dataUrls?: boolean; - exchangePdfLinks?: boolean; - extractHidden?: boolean; - firstPageToConvert?: number; - fontFullName?: boolean; - ignoreImages?: boolean; - imageFormat?: "JPG" | "PNG"; - lastPageToConvert?: number; - noDrm?: boolean; - noFrames?: boolean; - noMergeParagraph?: boolean; - noRoundedCoordinates?: boolean; - outputEncoding?: string; - ownerPassword?: string; - printVersionInfo?: boolean; - quiet?: boolean; - singlePage?: boolean; - stdout?: boolean; - userPassword?: string; - wordBreakThreshold?: number; - xmlOutput?: boolean; - zoom?: number; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {('no'|'yes')} [options.antialiasFonts] - Enable or disable font anti-aliasing. - * This defaults to `yes`. - * @param {('no'|'yes')} [options.antialiasVectors] - Enable or disable vector anti-aliasing. - * This defaults to `yes`. - * @param {boolean} [options.cropBox] - Uses the crop box rather than media box when - * generating the files (PNG/JPEG/TIFF only). - * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels - * (image output) or points (vector output). - * @param {number} [options.cropSize] - Specifies the size of crop square in pixels - * (image output) or points (vector output). - * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels - * (image output) or points (vector output). - * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left - * corner in pixels (image output) or points (vector output). - * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left - * corner in pixels (image output) or points (vector output). - * @param {string} [options.defaultCmykProfile] - 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. - * @param {string} [options.defaultGrayProfile] - 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. - * @param {string} [options.defaultRgbProfile] - 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. - * @param {string} [options.displayProfile] - 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. - * @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages. - * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. - * @param {('no'|'yes')} [options.freetype] - Enable or disable FreeType (a TrueType / Type 1 font rasterizer). - * This defaults to `yes`. - * @param {boolean} [options.forcePageNumber] - Force page number even if there is only one page. - * @param {boolean} [options.grayscaleFile] - Generate grayscale PGM file (instead of a color PPM file). - * @param {boolean} [options.hideAnnotations] - Hide annotations. - * @param {boolean} [options.jpegFile] - Generate JPEG file instead a PPM file. - * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. - * @param {boolean} [options.monochromeFile] - Generate monochrome PBM file (instead of a color PPM file). - * @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages. - * @param {string} [options.ownerPassword] - Specify the owner password for the PDF file. - * Providing this will bypass all security restrictions. - * @param {boolean} [options.pngFile] - Generate PNG file instead a PPM file. - * @param {boolean} [options.printProgress] - 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. - * @param {boolean} [options.printVersionInfo] - Print copyright and version information. - * @param {boolean} [options.quiet] - Do not print any messages or errors. - * @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of - * image files (or rasterized regions in vector output). The default is 150 PPI. - * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per - * inch of image files (or rasterized regions in vector output). The default is 150 PPI. - * @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of - * image files (or rasterized regions in vector output). The default is 150 PPI. - * @param {number} [options.scalePageTo] - 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. - * @param {number} [options.scalePageToXAxis] - 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. - * @param {number} [options.scalePageToYAxis] - 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. - * @param {string} [options.separator] - Specify single character separator between name and page number. - * @param {boolean} [options.singleFile] - Writes only the first page and does not add digits. - * @param {('none'|'shape'|'solid')} [options.thinLineMode] - Specifies the thin line mode. This defaults to `none`. - * @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression. - * @param {boolean} [options.tiffFile] - Generate TIFF file instead a PPM file. - * @param {string} [options.userPassword] - Specify the user password for the PDF file. - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfToPpm( - file: Buffer | string, - outputPath: string, - options?: { - antialiasFonts?: "no" | "yes"; - antialiasVectors?: "no" | "yes"; - cropBox?: boolean; - cropHeight?: number; - cropSize?: number; - cropWidth?: number; - cropXAxis?: number; - cropYAxis?: number; - defaultCmykProfile?: string; - defaultGrayProfile?: string; - defaultRgbProfile?: string; - displayProfile?: string; - evenPagesOnly?: boolean; - firstPageToConvert?: number; - freetype?: "no" | "yes"; - forcePageNumber?: boolean; - grayscaleFile?: boolean; - hideAnnotations?: boolean; - jpegFile?: boolean; - lastPageToConvert?: number; - monochromeFile?: boolean; - oddPagesOnly?: boolean; - ownerPassword?: string; - pngFile?: boolean; - printProgress?: boolean; - printVersionInfo?: boolean; - quiet?: boolean; - resolutionXAxis?: number; - resolutionXYAxis?: number; - resolutionYAxis?: number; - scalePageTo?: number; - scalePageToXAxis?: number; - scalePageToYAxis?: number; - separator?: string; - singleFile?: boolean; - thinLineMode?: "none" | "shape" | "solid"; - tiffCompression?: "deflate" | "jpeg" | "lzw" | "none" | "packbits"; - tiffFile?: boolean; - userPassword?: string; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {('no'|'yes')} [options.antialias] - Enable anti-aliasing on rasterization, accepts `no` or `yes`. - * @param {boolean} [options.binary] - 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. - * @param {string} [options.defaultCmykProfile] - 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. - * @param {string} [options.defaultGrayProfile] - 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. - * @param {string} [options.defaultRgbProfile] - 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. - * @param {boolean} [options.duplex] - Set the Duplex pagedevice entry in the PostScript file. - * This tells duplex-capable printers to enable duplexing. - * @param {boolean} [options.epsFile] - 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. - * @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the - * paper. By default, these pages are not scaled. - * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. - * @param {number} [options.form] - 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. - * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. - * @param {boolean} [options.level1] - 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. - * @param {boolean} [options.level1Sep] - Generate Level 1 separable PostScript. - * All colors are converted to CMYK. Images are written with separate stream data for the four components. - * @param {boolean} [options.level2] - Generate Level 2 PostScript. - * Level 2 supports color images and image compression. This is the default setting. - * @param {boolean} [options.level2Sep] - Generate Level 2 separable PostScript. All colors are - * converted to CMYK. The PostScript separation convention operators are used to handle custom (spot) colors. - * @param {boolean} [options.level3] - Generate Level 3 PostScript. - * This enables all Level 2 featuresplus CID font embedding. - * @param {boolean} [options.level3Sep] - Generate Level 3 separable PostScript. - * The separation handling is the same as for `options.level2Sep`. - * @param {boolean} [options.noEmbedCIDFonts] - 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. - * @param {boolean} [options.noEmbedCIDTrueTypeFonts] - 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. - * @param {boolean} [options.noEmbedTrueTypeFonts] - 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. - * @param {boolean} [options.noEmbedType1Fonts] - 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. - * @param {boolean} [options.noCenter] - 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. - * @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox - * specified in the PDF file. This option disables cropping. - * @param {boolean} [options.noShrink] - Do not scale PDF pages which are larger than the paper. - * By default, pages larger than the paper are shrunk to fit. - * @param {boolean} [options.opi] - Generate OPI comments for all images and forms which have OPI information. - * @param {boolean} [options.optimizecolorspace] - 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. - * @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match - * the size specified in the PDF file. - * @param {boolean} [options.overprint] - Enable overprinting. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {number} [options.paperHeight] - Set the paper height, in points. - * @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - 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. - * @param {number} [options.paperWidth] - Set the paper width, in points. - * @param {boolean} [options.passfonts] - 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. - * @param {boolean} [options.preload] - Preload images and forms. - * @param {boolean} [options.printVersionInfo] - Print copyright and version information. - * @param {('CMYK8'|'MONO8'|'RGB8')} [options.processColorFormat] - 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. - * @param {string} [options.processColorProfile] - Sets the ICC profile that is assumed during - * rasterization and transparency reduction. - * @param {boolean} [options.quiet] - Do not print any messages or errors. - * @param {('always'|'never'|'whenneeded')} [options.rasterize] - 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. - * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per - * inch of image files (or rasterized regions in vector output). The default is 300 PPI. - * @param {string} [options.userPassword] - User password (for encrypted files). - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfToPs( - file: Buffer | string, - outputFile?: string, - options?: { - antialias?: "no" | "yes"; - binary?: boolean; - defaultCmykProfile?: string; - defaultGrayProfile?: string; - defaultRgbProfile?: string; - duplex?: boolean; - epsFile?: boolean; - fillPage?: boolean; - firstPageToConvert?: number; - form?: number; - lastPageToConvert?: number; - level1?: boolean; - level1Sep?: boolean; - level2?: boolean; - level2Sep?: boolean; - level3?: boolean; - level3Sep?: boolean; - noEmbedCIDFonts?: boolean; - noEmbedCIDTrueTypeFonts?: boolean; - noEmbedTrueTypeFonts?: boolean; - noEmbedType1Fonts?: boolean; - noCenter?: boolean; - noCrop?: boolean; - noShrink?: boolean; - opi?: boolean; - optimizecolorspace?: boolean; - originalPageSizes?: boolean; - overprint?: boolean; - ownerPassword?: string; - paperHeight?: number; - paperSize?: "A3" | "A4" | "legal" | "letter" | "match"; - paperWidth?: number; - passfonts?: boolean; - preload?: boolean; - printVersionInfo?: boolean; - processColorFormat?: "CMYK8" | "MONO8" | "RGB8"; - processColorProfile?: string; - quiet?: boolean; - rasterize?: "always" | "never" | "whenneeded"; - resolutionXYAxis?: number; - userPassword?: string; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {boolean} [options.boundingBoxXhtml] - Generate an XHTML file containing bounding - * box information for each word in the file. - * @param {boolean} [options.boundingBoxXhtmlLayout] - Generate an XHTML file containing - * bounding box information for each block, line, and word in the file. - * @param {boolean} [options.cropBox] - Use the crop box rather than the media box with - * `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout` - * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels - * (image output) or points (vector output). - * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels - * (image output) or points (vector output). - * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left - * corner in pixels (image output) or points (vector output). - * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left - * corner in pixels (image output) or points (vector output). - * @param {('dos'|'mac'|'unix')} [options.eolConvention] - Sets the end-of-line convention to use for - * text output: dos; mac; unix. - * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. - * @param {number} [options.fixedWidthLayout] - Assume fixed-pitch (or tabular) text, with the - * specified character width (in points). This forces physical layout mode. - * @param {boolean} [options.generateHtmlMetaFile] - Generate simple HTML file, including the - * meta information. This simply wraps the text in `
` and `
` and prepends the meta headers. - * @param {boolean} [options.generateTsvFile] - Generate a TSV file containing the bounding box - * information for each block, line, and word in the file. - * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. - * @param {boolean} [options.listEncodingOptions] - List the available encodings. - * @param {boolean} [options.maintainLayout] - 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. - * @param {boolean} [options.noDiagonalText] - Discard diagonal text. - * @param {boolean} [options.noPageBreaks] - Do not insert page breaks (form feed characters) - * between pages. - * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. - * This defaults to `UTF-8`. - * @param {string} [options.ownerPassword] - Owner password (for encrypted files). - * @param {boolean} [options.printVersionInfo] - Print copyright and version information. - * @param {boolean} [options.quiet] - Do not print any messages or errors. - * @param {boolean} [options.rawLayout] - 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. - * @param {string} [options.userPassword] - User password (for encrypted files). - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfToText( - file: Buffer | string, - outputFile?: string, - options?: { - boundingBoxXhtml?: boolean; - boundingBoxXhtmlLayout?: boolean; - cropBox?: boolean; - cropHeight?: number; - cropWidth?: number; - cropXAxis?: number; - cropYAxis?: number; - eolConvention?: "dos" | "mac" | "unix"; - firstPageToConvert?: number; - fixedWidthLayout?: number; - generateHtmlMetaFile?: boolean; - generateTsvFile?: boolean; - lastPageToConvert?: number; - listEncodingOptions?: boolean; - maintainLayout?: boolean; - noDiagonalText?: boolean; - noPageBreaks?: boolean; - outputEncoding?: string; - ownerPassword?: string; - printVersionInfo?: boolean; - quiet?: boolean; - rawLayout?: boolean; - userPassword?: string; - } - ): Promise; - /** - * @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 {object} [options] - Object containing options to pass to binary. - * @param {boolean} [options.printVersionInfo] - Print copyright and version information. - * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. - */ - pdfUnite( - files: string[], - outputFile: string, - options?: { - printVersionInfo?: boolean; - } - ): Promise; + /** @param {string} [binPath] - Path of poppler-utils binaries. */ + constructor(binPath?: string); + popplerPath: 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 {object} [options] - Object containing options to pass to binary. + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @param {boolean} [options.replace] - Replace embedded file with same name (if it exists). + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfAttach(file: string, fileToAttach: string, outputFile: string, options?: { + printVersionInfo?: boolean; + replace?: boolean; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {boolean} [options.listEmbedded] - List all of the embedded files in the PDF file. + * File names are converted to the text encoding specified by `options.outputEncoding`. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. + * This defaults to `UTF-8`. + * @param {string} [options.outputPath] - Set the file name used when saving an embedded file with + * the save option enabled, or the directory if `options.saveall` is used. + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @param {boolean} [options.saveAllFiles] - 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`. + * @param {string} [options.saveFile] - 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`. + * @param {number} [options.saveSpecificFile] - 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`. + * @param {string} [options.userPassword] - User password (for encrypted files). + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfDetach(file: string, options?: { + listEmbedded?: boolean; + ownerPassword?: string; + outputEncoding?: string; + outputPath?: string; + printVersionInfo?: boolean; + saveAllFiles?: boolean; + saveFile?: string; + saveSpecificFile?: number; + userPassword?: string; + }): Promise; + /** + * @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 {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. + * @param {boolean} [options.listSubstitutes] - List the substitute fonts that poppler + * will use for non-embedded fonts. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @param {string} [options.userPassword] - User password (for encrypted files). + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfFonts(file: Buffer | string, options?: { + firstPageToExamine?: number; + lastPageToExamine?: number; + listSubstitutes?: boolean; + ownerPassword?: string; + printVersionInfo?: boolean; + userPassword?: string; + }): Promise; + /** + * @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 {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. + * @param {boolean} [options.ccittFile] - Generate CCITT images as CCITT files. + * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. + * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. + * @param {boolean} [options.list] - Instead of writing the images, list the + * images along with various information for each image. + * NOTE: Do not specify the outputPrefix with this option. + * @param {boolean} [options.jbig2File] - Generate JBIG2 images as JBIG2 files. + * @param {boolean} [options.jpeg2000File] - Generate JPEG2000 images at JP2 files. + * @param {boolean} [options.jpegFile] - Generate JPEG images as JPEG files. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {boolean} [options.pngFile] - Change the default output format to PNG. + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @param {boolean} [options.tiffFile] - Change the default output format to TIFF. + * @param {string} [options.userPassword] - Specify the user password for the PDF file. + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfImages(file: Buffer | string, outputPrefix?: string, options?: { + allFiles?: boolean; + ccittFile?: boolean; + firstPageToConvert?: number; + lastPageToConvert?: number; + list?: boolean; + jbig2File?: boolean; + jpeg2000File?: boolean; + jpegFile?: boolean; + ownerPassword?: string; + pngFile?: boolean; + printVersionInfo?: boolean; + tiffFile?: boolean; + userPassword?: string; + }): Promise; + /** + * @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 {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. + * @param {boolean} [options.listEncodingOptions] - List the available encodings. + * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. + * This defaults to `UTF-8`. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {boolean} [options.printAsJson] - Print result as a JSON object. + * @param {boolean} [options.printBoundingBoxes] - Prints the page box bounding boxes: + * MediaBox, CropBox, BleedBox, TrimBox, and ArtBox. + * @param {boolean} [options.printDocStruct] - Prints the logical document structure + * of a Tagged-PDF file. + * @param {boolean} [options.printDocStructText] - 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. + * @param {boolean} [options.printIsoDates] - Prints dates in ISO-8601 format (including the time zone). + * @param {boolean} [options.printJS] - Prints all JavaScript in the PDF file. + * @param {boolean} [options.printMetadata] - Prints document-level metadata. (This is the `Metadata` + * stream from the PDF file's Catalog object). + * @param {boolean} [options.printNamedDests] - 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. + * @param {boolean} [options.printRawDates] - Prints the raw (undecoded) date strings, directly from the PDF file. + * @param {boolean} [options.printUrls] - 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. + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @param {string} [options.userPassword] - User password (for encrypted files). + * @returns {Promise} 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?: { + firstPageToConvert?: number; + lastPageToConvert?: number; + listEncodingOptions?: boolean; + outputEncoding?: string; + ownerPassword?: string; + printAsJson?: boolean; + printBoundingBoxes?: boolean; + printDocStruct?: boolean; + printDocStructText?: boolean; + printIsoDates?: boolean; + printJS?: boolean; + printMetadata?: boolean; + printNamedDests?: boolean; + printRawDates?: boolean; + printUrls?: boolean; + printVersionInfo?: boolean; + userPassword?: string; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {number} [options.firstPageToExtract] - Specifies the first page to extract. + * This defaults to page 1. + * @param {number} [options.lastPageToExtract] - Specifies the last page to extract. + * This defaults to the last page of the PDF file. + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfSeparate(file: string, outputPattern: string, options?: { + firstPageToExtract?: number; + lastPageToExtract?: number; + printVersionInfo?: boolean; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {('best'|'default'|'fast'|'good'|'gray'|'none'|'subpixel')} [options.antialias] - Set the cairo + * antialias option used for text and drawing in image files (or rasterized regions in vector output). + * @param {boolean} [options.cropBox] - Uses the crop box rather than media box when + * generating the files (PNG/JPEG/TIFF only). + * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels + * (image output) or points (vector output). + * @param {number} [options.cropSize] - Specifies the size of crop square in pixels + * (image output) or points (vector output). + * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels + * (image output) or points (vector output). + * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left + * corner in pixels (image output) or points (vector output). + * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left + * corner in pixels (image output) or points (vector output). + * @param {boolean} [options.duplex] - Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC + * comment to the PostScript file (PS only). This tells the print manager to enable duplexing. + * @param {boolean} [options.epsFile] - 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. + * @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages. + * @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the + * paper (PS,PDF,SVG only). By default, these pages are not scaled. + * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. + * @param {boolean} [options.grayscaleFile] - Generate grayscale file (PNG, JPEG, and TIFF only). + * @param {string} [options.iccFile] - Use the specified ICC file as the output profile + * (PNG only). The profile will be embedded in the PNG file. + * @param {boolean} [options.jpegFile] - Generate JPEG file(s). + * @param {string} [options.jpegOptions] - When used with `options.jpegFile`, this option can + * be used to control the JPEG compression parameters. It takes a string of the form + * `"=[,=]"`. 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"`. + * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. + * @param {boolean} [options.monochromeFile] - Generate monochrome file (PNG and TIFF only). + * @param {boolean} [options.noCenter] - 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). + * @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox + * specified in the PDF file. This option disables cropping (PS, PDF, SVG only). + * @param {boolean} [options.noShrink] - 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. + * @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages. + * @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match + * the size specified in the PDF file. + * @param {string} [options.ownerPassword] - Specify the owner password for the PDF file. + * Providing this will bypass all security restrictions. + * @param {number} [options.paperHeight] - Set the paper height, in points (PS, PDF, SVG only). + * @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - 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. + * @param {number} [options.paperWidth] - Set the paper width, in points (PS,PDF,SVG only). + * @param {boolean} [options.pdfFile] - Generate PDF file. + * @param {boolean} [options.pngFile] - Generate PNG file(s). + * @param {boolean} [options.printVersionInfo] - Print copyright and version information. + * @param {boolean} [options.printDocStruct] - If the input file contains structural information + * about the document's content, write this information to the output file (PDF only). + * @param {boolean} [options.psFile] - Generate PS file. + * @param {boolean} [options.psLevel2] - Generate Level 2 PostScript (PS only). + * @param {boolean} [options.psLevel3] - Generate Level 3 PostScript (PS only). This enables all + * Level 2 features plus shading patterns and masked images. This is the default setting. + * @param {boolean} [options.quiet] - Do not print any messages or errors. + * @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of + * image files (or rasterized regions in vector output). The default is 150 PPI. + * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per + * inch of image files (or rasterized regions in vector output). The default is 150 PPI. + * @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of + * image files (or rasterized regions in vector output). The default is 150 PPI. + * @param {number} [options.scalePageTo] - 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). + * @param {number} [options.scalePageToXAxis] - 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). + * @param {number} [options.scalePageToYAxis] - 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). + * @param {boolean} [options.singleFile] - Writes only the first page and does not add digits. + * Can only be used with `options.jpegFile`, `options.pngFile`, and `options.tiffFile`. + * @param {boolean} [options.svgFile] - Generate SVG (Scalable Vector Graphics) file. + * @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression. + * @param {boolean} [options.tiffFile] - Generate TIFF file(s). + * @param {boolean} [options.transparentPageColor] - Use a transparent page color + * instead of white (PNG and TIFF only). + * @param {string} [options.userPassword] - Specify the user password for the PDF file. + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfToCairo(file: Buffer | string, outputFile?: string, options?: { + antialias?: ('best' | 'default' | 'fast' | 'good' | 'gray' | 'none' | 'subpixel'); + cropBox?: boolean; + cropHeight?: number; + cropSize?: number; + cropWidth?: number; + cropXAxis?: number; + cropYAxis?: number; + duplex?: boolean; + epsFile?: boolean; + evenPagesOnly?: boolean; + fillPage?: boolean; + firstPageToConvert?: number; + grayscaleFile?: boolean; + iccFile?: string; + jpegFile?: boolean; + jpegOptions?: string; + lastPageToConvert?: number; + monochromeFile?: boolean; + noCenter?: boolean; + noCrop?: boolean; + noShrink?: boolean; + oddPagesOnly?: boolean; + originalPageSizes?: boolean; + ownerPassword?: string; + paperHeight?: number; + paperSize?: ('A3' | 'A4' | 'legal' | 'letter' | 'match'); + paperWidth?: number; + pdfFile?: boolean; + pngFile?: boolean; + printVersionInfo?: boolean; + printDocStruct?: boolean; + psFile?: boolean; + psLevel2?: boolean; + psLevel3?: boolean; + quiet?: boolean; + resolutionXAxis?: number; + resolutionXYAxis?: number; + resolutionYAxis?: number; + scalePageTo?: number; + scalePageToXAxis?: number; + scalePageToYAxis?: number; + singleFile?: boolean; + svgFile?: boolean; + tiffCompression?: ('deflate' | 'jpeg' | 'lzw' | 'none' | 'packbits'); + tiffFile?: boolean; + transparentPageColor?: boolean; + userPassword?: string; + }): Promise; + /** + * @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 {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. + * @param {boolean} [options.exchangePdfLinks] - Exchange .pdf links with .html. + * @param {boolean} [options.extractHidden] - Force hidden text extraction. + * @param {number} [options.firstPageToConvert] - First page to print. + * @param {boolean} [options.fontFullName] - Outputs the font name without any substitutions. + * @param {boolean} [options.ignoreImages] - Ignore images. + * @param {('JPG'|'PNG')} [options.imageFormat] - Image file format for Splash output (JPG or PNG). + * If complexOutput is selected, but imageFormat is not specified, PNG will be assumed. + * @param {number} [options.lastPageToConvert] - Last page to print. + * @param {boolean} [options.noDrm] - Override document DRM settings. + * @param {boolean} [options.noFrames] - Generate no frames. Not supported in complex output mode. + * @param {boolean} [options.noMergeParagraph] - Do not merge paragraphs. + * @param {boolean} [options.noRoundedCoordinates] - Do not round coordinates + * (with XML output only). + * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. + * This defaults to `UTF-8`. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {boolean} [options.printVersionInfo] - Print copyright and version info. + * @param {boolean} [options.quiet] - Do not print any messages or errors. + * @param {boolean} [options.singlePage] - Generate single HTML that includes all pages. + * @param {boolean} [options.stdout] - Use standard output. + * @param {string} [options.userPassword] - User password (for encrypted files). + * @param {number} [options.wordBreakThreshold] - 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. + * @param {boolean} [options.xmlOutput] - Output for XML post-processing. + * @param {number} [options.zoom] - Zoom the PDF document (default 1.5). + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfToHtml(file: Buffer | string, outputFile?: string, options?: { + complexOutput?: boolean; + dataUrls?: boolean; + exchangePdfLinks?: boolean; + extractHidden?: boolean; + firstPageToConvert?: number; + fontFullName?: boolean; + ignoreImages?: boolean; + imageFormat?: ('JPG' | 'PNG'); + lastPageToConvert?: number; + noDrm?: boolean; + noFrames?: boolean; + noMergeParagraph?: boolean; + noRoundedCoordinates?: boolean; + outputEncoding?: string; + ownerPassword?: string; + printVersionInfo?: boolean; + quiet?: boolean; + singlePage?: boolean; + stdout?: boolean; + userPassword?: string; + wordBreakThreshold?: number; + xmlOutput?: boolean; + zoom?: number; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {('no'|'yes')} [options.antialiasFonts] - Enable or disable font anti-aliasing. + * This defaults to `yes`. + * @param {('no'|'yes')} [options.antialiasVectors] - Enable or disable vector anti-aliasing. + * This defaults to `yes`. + * @param {boolean} [options.cropBox] - Uses the crop box rather than media box when + * generating the files (PNG/JPEG/TIFF only). + * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels + * (image output) or points (vector output). + * @param {number} [options.cropSize] - Specifies the size of crop square in pixels + * (image output) or points (vector output). + * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels + * (image output) or points (vector output). + * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left + * corner in pixels (image output) or points (vector output). + * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left + * corner in pixels (image output) or points (vector output). + * @param {string} [options.defaultCmykProfile] - 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. + * @param {string} [options.defaultGrayProfile] - 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. + * @param {string} [options.defaultRgbProfile] - 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. + * @param {string} [options.displayProfile] - 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. + * @param {boolean} [options.evenPagesOnly] - Generates only the even numbered pages. + * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. + * @param {('no'|'yes')} [options.freetype] - Enable or disable FreeType (a TrueType / Type 1 font rasterizer). + * This defaults to `yes`. + * @param {boolean} [options.forcePageNumber] - Force page number even if there is only one page. + * @param {boolean} [options.grayscaleFile] - Generate grayscale PGM file (instead of a color PPM file). + * @param {boolean} [options.hideAnnotations] - Hide annotations. + * @param {boolean} [options.jpegFile] - Generate JPEG file instead a PPM file. + * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. + * @param {boolean} [options.monochromeFile] - Generate monochrome PBM file (instead of a color PPM file). + * @param {boolean} [options.oddPagesOnly] - Generates only the odd numbered pages. + * @param {string} [options.ownerPassword] - Specify the owner password for the PDF file. + * Providing this will bypass all security restrictions. + * @param {boolean} [options.pngFile] - Generate PNG file instead a PPM file. + * @param {boolean} [options.printProgress] - 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. + * @param {boolean} [options.printVersionInfo] - Print copyright and version information. + * @param {boolean} [options.quiet] - Do not print any messages or errors. + * @param {number} [options.resolutionXAxis] - Specifies the X resolution, in pixels per inch of + * image files (or rasterized regions in vector output). The default is 150 PPI. + * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per + * inch of image files (or rasterized regions in vector output). The default is 150 PPI. + * @param {number} [options.resolutionYAxis] - Specifies the Y resolution, in pixels per inch of + * image files (or rasterized regions in vector output). The default is 150 PPI. + * @param {number} [options.scalePageTo] - 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. + * @param {number} [options.scalePageToXAxis] - 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. + * @param {number} [options.scalePageToYAxis] - 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. + * @param {string} [options.separator] - Specify single character separator between name and page number. + * @param {boolean} [options.singleFile] - Writes only the first page and does not add digits. + * @param {('none'|'shape'|'solid')} [options.thinLineMode] - Specifies the thin line mode. This defaults to `none`. + * @param {('deflate'|'jpeg'|'lzw'|'none'|'packbits')} [options.tiffCompression] - Set TIFF compression. + * @param {boolean} [options.tiffFile] - Generate TIFF file instead a PPM file. + * @param {string} [options.userPassword] - Specify the user password for the PDF file. + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfToPpm(file: Buffer | string, outputPath: string, options?: { + antialiasFonts?: ('no' | 'yes'); + antialiasVectors?: ('no' | 'yes'); + cropBox?: boolean; + cropHeight?: number; + cropSize?: number; + cropWidth?: number; + cropXAxis?: number; + cropYAxis?: number; + defaultCmykProfile?: string; + defaultGrayProfile?: string; + defaultRgbProfile?: string; + displayProfile?: string; + evenPagesOnly?: boolean; + firstPageToConvert?: number; + freetype?: ('no' | 'yes'); + forcePageNumber?: boolean; + grayscaleFile?: boolean; + hideAnnotations?: boolean; + jpegFile?: boolean; + lastPageToConvert?: number; + monochromeFile?: boolean; + oddPagesOnly?: boolean; + ownerPassword?: string; + pngFile?: boolean; + printProgress?: boolean; + printVersionInfo?: boolean; + quiet?: boolean; + resolutionXAxis?: number; + resolutionXYAxis?: number; + resolutionYAxis?: number; + scalePageTo?: number; + scalePageToXAxis?: number; + scalePageToYAxis?: number; + separator?: string; + singleFile?: boolean; + thinLineMode?: ('none' | 'shape' | 'solid'); + tiffCompression?: ('deflate' | 'jpeg' | 'lzw' | 'none' | 'packbits'); + tiffFile?: boolean; + userPassword?: string; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {('no'|'yes')} [options.antialias] - Enable anti-aliasing on rasterization, accepts `no` or `yes`. + * @param {boolean} [options.binary] - 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. + * @param {string} [options.defaultCmykProfile] - 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. + * @param {string} [options.defaultGrayProfile] - 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. + * @param {string} [options.defaultRgbProfile] - 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. + * @param {boolean} [options.duplex] - Set the Duplex pagedevice entry in the PostScript file. + * This tells duplex-capable printers to enable duplexing. + * @param {boolean} [options.epsFile] - 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. + * @param {boolean} [options.fillPage] - Expand PDF pages smaller than the paper to fill the + * paper. By default, these pages are not scaled. + * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. + * @param {number} [options.form] - 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. + * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. + * @param {boolean} [options.level1] - 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. + * @param {boolean} [options.level1Sep] - Generate Level 1 separable PostScript. + * All colors are converted to CMYK. Images are written with separate stream data for the four components. + * @param {boolean} [options.level2] - Generate Level 2 PostScript. + * Level 2 supports color images and image compression. This is the default setting. + * @param {boolean} [options.level2Sep] - Generate Level 2 separable PostScript. All colors are + * converted to CMYK. The PostScript separation convention operators are used to handle custom (spot) colors. + * @param {boolean} [options.level3] - Generate Level 3 PostScript. + * This enables all Level 2 featuresplus CID font embedding. + * @param {boolean} [options.level3Sep] - Generate Level 3 separable PostScript. + * The separation handling is the same as for `options.level2Sep`. + * @param {boolean} [options.noEmbedCIDFonts] - 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. + * @param {boolean} [options.noEmbedCIDTrueTypeFonts] - 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. + * @param {boolean} [options.noEmbedTrueTypeFonts] - 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. + * @param {boolean} [options.noEmbedType1Fonts] - 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. + * @param {boolean} [options.noCenter] - 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. + * @param {boolean} [options.noCrop] - By default, printing output is cropped to the CropBox + * specified in the PDF file. This option disables cropping. + * @param {boolean} [options.noShrink] - Do not scale PDF pages which are larger than the paper. + * By default, pages larger than the paper are shrunk to fit. + * @param {boolean} [options.opi] - Generate OPI comments for all images and forms which have OPI information. + * @param {boolean} [options.optimizecolorspace] - 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. + * @param {boolean} [options.originalPageSizes] - Set the paper size of each page to match + * the size specified in the PDF file. + * @param {boolean} [options.overprint] - Enable overprinting. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {number} [options.paperHeight] - Set the paper height, in points. + * @param {('A3'|'A4'|'legal'|'letter'|'match')} [options.paperSize] - 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. + * @param {number} [options.paperWidth] - Set the paper width, in points. + * @param {boolean} [options.passfonts] - 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. + * @param {boolean} [options.preload] - Preload images and forms. + * @param {boolean} [options.printVersionInfo] - Print copyright and version information. + * @param {('CMYK8'|'MONO8'|'RGB8')} [options.processColorFormat] - 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. + * @param {string} [options.processColorProfile] - Sets the ICC profile that is assumed during + * rasterization and transparency reduction. + * @param {boolean} [options.quiet] - Do not print any messages or errors. + * @param {('always'|'never'|'whenneeded')} [options.rasterize] - 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. + * @param {number} [options.resolutionXYAxis] - Specifies the X and Y resolution, in pixels per + * inch of image files (or rasterized regions in vector output). The default is 300 PPI. + * @param {string} [options.userPassword] - User password (for encrypted files). + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfToPs(file: Buffer | string, outputFile?: string, options?: { + antialias?: ('no' | 'yes'); + binary?: boolean; + defaultCmykProfile?: string; + defaultGrayProfile?: string; + defaultRgbProfile?: string; + duplex?: boolean; + epsFile?: boolean; + fillPage?: boolean; + firstPageToConvert?: number; + form?: number; + lastPageToConvert?: number; + level1?: boolean; + level1Sep?: boolean; + level2?: boolean; + level2Sep?: boolean; + level3?: boolean; + level3Sep?: boolean; + noEmbedCIDFonts?: boolean; + noEmbedCIDTrueTypeFonts?: boolean; + noEmbedTrueTypeFonts?: boolean; + noEmbedType1Fonts?: boolean; + noCenter?: boolean; + noCrop?: boolean; + noShrink?: boolean; + opi?: boolean; + optimizecolorspace?: boolean; + originalPageSizes?: boolean; + overprint?: boolean; + ownerPassword?: string; + paperHeight?: number; + paperSize?: ('A3' | 'A4' | 'legal' | 'letter' | 'match'); + paperWidth?: number; + passfonts?: boolean; + preload?: boolean; + printVersionInfo?: boolean; + processColorFormat?: ('CMYK8' | 'MONO8' | 'RGB8'); + processColorProfile?: string; + quiet?: boolean; + rasterize?: ('always' | 'never' | 'whenneeded'); + resolutionXYAxis?: number; + userPassword?: string; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {boolean} [options.boundingBoxXhtml] - Generate an XHTML file containing bounding + * box information for each word in the file. + * @param {boolean} [options.boundingBoxXhtmlLayout] - Generate an XHTML file containing + * bounding box information for each block, line, and word in the file. + * @param {boolean} [options.cropBox] - Use the crop box rather than the media box with + * `options.boundingBoxXhtml` and `options.boundingBoxXhtmlLayout`. + * @param {number} [options.cropHeight] - Specifies the height of crop area in pixels + * (image output) or points (vector output). + * @param {number} [options.cropWidth] - Specifies the width of crop area in pixels + * (image output) or points (vector output). + * @param {number} [options.cropXAxis] - Specifies the x-coordinate of the crop area top left + * corner in pixels (image output) or points (vector output). + * @param {number} [options.cropYAxis] - Specifies the y-coordinate of the crop area top left + * corner in pixels (image output) or points (vector output). + * @param {('dos'|'mac'|'unix')} [options.eolConvention] - Sets the end-of-line convention to use for + * text output: dos; mac; unix. + * @param {number} [options.firstPageToConvert] - Specifies the first page to convert. + * @param {number} [options.fixedWidthLayout] - Assume fixed-pitch (or tabular) text, with the + * specified character width (in points). This forces physical layout mode. + * @param {boolean} [options.generateHtmlMetaFile] - Generate simple HTML file, including the + * meta information. This simply wraps the text in `
` and `
` and prepends the meta headers. + * @param {boolean} [options.generateTsvFile] - Generate a TSV file containing the bounding box + * information for each block, line, and word in the file. + * @param {number} [options.lastPageToConvert] - Specifies the last page to convert. + * @param {boolean} [options.listEncodingOptions] - List the available encodings. + * @param {boolean} [options.maintainLayout] - 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. + * @param {boolean} [options.noDiagonalText] - Discard diagonal text. + * @param {boolean} [options.noPageBreaks] - Do not insert page breaks (form feed characters) + * between pages. + * @param {string} [options.outputEncoding] - Sets the encoding to use for text output. + * This defaults to `UTF-8`. + * @param {string} [options.ownerPassword] - Owner password (for encrypted files). + * @param {boolean} [options.printVersionInfo] - Print copyright and version information. + * @param {boolean} [options.quiet] - Do not print any messages or errors. + * @param {boolean} [options.rawLayout] - 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. + * @param {string} [options.userPassword] - User password (for encrypted files). + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfToText(file: Buffer | string, outputFile?: string, options?: { + boundingBoxXhtml?: boolean; + boundingBoxXhtmlLayout?: boolean; + cropBox?: boolean; + cropHeight?: number; + cropWidth?: number; + cropXAxis?: number; + cropYAxis?: number; + eolConvention?: ('dos' | 'mac' | 'unix'); + firstPageToConvert?: number; + fixedWidthLayout?: number; + generateHtmlMetaFile?: boolean; + generateTsvFile?: boolean; + lastPageToConvert?: number; + listEncodingOptions?: boolean; + maintainLayout?: boolean; + noDiagonalText?: boolean; + noPageBreaks?: boolean; + outputEncoding?: string; + ownerPassword?: string; + printVersionInfo?: boolean; + quiet?: boolean; + rawLayout?: boolean; + userPassword?: string; + }): Promise; + /** + * @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 {object} [options] - Object containing options to pass to binary. + * @param {boolean} [options.printVersionInfo] - Print copyright and version information. + * @returns {Promise} A promise that resolves with a stdout string, or rejects with an `Error` object. + */ + pdfUnite(files: string[], outputFile: string, options?: { + printVersionInfo?: boolean; + }): Promise; }