# @isneezy/pdf-generator-cli

> A powerful and versatile command line interface for converting HTML pages, templates, and URLs into high-quality PDF documents.

Latest version **0.0.1** (published 2023-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @isneezy/pdf-generator-cli
pnpm add @isneezy/pdf-generator-cli
yarn add @isneezy/pdf-generator-cli
bun add @isneezy/pdf-generator-cli
```

Provides the command `pdf-generator`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-01-23 |
| First published | 2023-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Ivan Vilanculo |
| Maintainers | isneezy |
| Keywords | HTML, to, PDF, TOC, Converter, generator |

## Links

- npm: https://www.npmjs.com/package/@isneezy/pdf-generator-cli
- Repository: https://github.com/isneezy/pdf-generator-service
- Homepage: https://github.com/isneezy/pdf-generator-service/tree/main/packages/pdf-generator-cli#readme
- Issues: https://github.com/isneezy/pdf-generator-service/issues
- npm.io page: https://npm.io/package/@isneezy/pdf-generator-cli

## Dependencies (2)

- [commander](https://npm.io/package/commander.md) ^10.0.0
- [@isneezy/pdf-generator](https://npm.io/package/@isneezy/pdf-generator.md) ^0.0.1

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-01-23
- 1.1.3 (next) — 2023-01-24
- 1.1.2 — 2023-01-24
- 1.1.1 — 2023-01-24
- 1.1.0 — 2023-01-24
- 1.0.1 — 2023-01-23
- 1.0.0 — 2023-01-23

## README

# @isneezy/pdf-generator-cli

`@isneezy/pdf-generator-cli` is a command line interface for the [`@isneezy/pdf-generator`](../library/README.md) library, it allows you to easily generate PDFs from the command line.

The package provides a single command `pdf-generator` that you can use to generate PDFs from a URL, HTML content or handlebars template with the context data.

# Installation
To install the package, you can use npm or yarn.

```shell
npm install -g @isneezy/pdf-generator-cli
```

```shell
yarn global add @isneezy/pdf-generator-cli
```

## Usage

The package provides a single command `pdf-generator` that you can use to generate PDFs.

```shell
pdf-generator [options]
```

| Option              | Type      | Default | Description                                                                                                                                                       |
|---------------------|-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -V, --version       |           |         | Output the version number                                                                                                                                         |
| -g, --goto          | `string`  |         | URL to the HTML content/handlebars template to be converted to PDF. If provided, it takes priority over the template option.                                      |
| -t, --template      | `string`  |         | Path to HTML/handlebars template or string containing HTML/handlebars template to be converted to PDF. If a goto option is provided, this option will be ignored. |
| -c, --context       | `string`  |         | Path to json file or json or json string with the data to be passed to the HTML template                                                                          |
| -f, --format        | `string`  | `A4`    | Sets the paper format to be used when printing a PDF. Accepted values include: letter, legal, tabloid, ledger, a0, a1, a2, a3, a4, a5, a6.                        |
| -H, --header-template | `string`  |         | String containing the template to the header, if set this takes priority over the header template in the document                                                 |
| -F, --footer-template | `string`  |         | String containing the template to the footer, if set this takes priority over the footer template in the document                                                 |
| -L, --landscape     | `boolean` | `false` | Use this flag to switch the orientation from portrait to landscape                                                                                                |
| -M, --margin | string | `10mm`  | Set the page margins. The margin option can be set in the following formats: <br/><ul><li>"margin" : sets the same margin for all four sides (top, bottom, left, right). Eg: <code>10mm</code></li><li>"top-bottom,left-right" : sets the same margin for top and bottom, and the same margin for left and right. Eg: <code>10mm,5mm</code></li><li>"top,bottom,left,right" : sets different margins for each side. Eg: <code>3mm,10mm,4mm,9mm</code></li></ul>
| -o, --output        | string    |         | Path to the output PDF file                                                                                                                                       |

The command takes the same options as the
[`generate`](../library/README.md#generate--options--options---promiseltbuffergt) method in the
[`@isneezy/pdf-generator`](../library/README.md) library, and it generates the PDF file in the specified `output` path.

Here is an example of how to use the command to generate a PDF from a handlebars template and context data:
```shell
pdf-generator -t "path/to/template.html" -c "path/to/context.json" -o "path/to/output.pdf"
# Or you can pass the template and context strings directly
pdf-generator -t "<p>My {{ name }}</p>" -c '{ name: "template"}' -o "path/to/output.pdf"
```

---
_Source: https://npm.io/package/@isneezy/pdf-generator-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
