0.0.1 • Published 1 year ago

@isneezy/pdf-generator-cli v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@isneezy/pdf-generator-cli

@isneezy/pdf-generator-cli is a command line interface for the @isneezy/pdf-generator 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.

npm install -g @isneezy/pdf-generator-cli
yarn global add @isneezy/pdf-generator-cli

Usage

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

pdf-generator [options]
OptionTypeDefaultDescription
-V, --versionOutput the version number
-g, --gotostringURL to the HTML content/handlebars template to be converted to PDF. If provided, it takes priority over the template option.
-t, --templatestringPath 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, --contextstringPath to json file or json or json string with the data to be passed to the HTML template
-f, --formatstringA4Sets 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-templatestringString containing the template to the header, if set this takes priority over the header template in the document
-F, --footer-templatestringString containing the template to the footer, if set this takes priority over the footer template in the document
-L, --landscapebooleanfalseUse this flag to switch the orientation from portrait to landscape
-M, --marginstring10mmSet the page margins. The margin option can be set in the following formats: "margin" : sets the same margin for all four sides (top, bottom, left, right). Eg: 10mm"top-bottom,left-right" : sets the same margin for top and bottom, and the same margin for left and right. Eg: 10mm,5mm"top,bottom,left,right" : sets different margins for each side. Eg: 3mm,10mm,4mm,9mm
-o, --outputstringPath to the output PDF file

The command takes the same options as the generate method in the @isneezy/pdf-generator 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:

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"
1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago