HTML to PDF in Command Line

This page describes how to use our cloud-based API to convert web pages and HTML to PDF from the command line. For general information about the converter, please visit our HTML to PDF API page.

Installation

Install the application from PyPI
pip install pdfcrowd

We also offer other installation options.

Authentication

The credentials to access the API are your Pdfcrowd username and the API key. You can try out the API without registering using the following demo credentials:

  • Username: demo
  • API key: ce544b6ea52a5621fb9d55f8b542d14d

To get your personal API credentials, you can start a free API trial or buy the API license.

Getting Started

You can enter a web page or upload an HTML file to get a PDF output preview in our API playground. The playground allows you to interactively play with the API settings and autogenerates corresponding Command Line code that you can copy and paste to your application.

Or you can choose from the examples below and adapt the code to your needs.

User Manual

Refer to the HTML to PDF Command Line Reference Manual for a description of all command line options.

Code Examples

Here are a few Command Line examples to get you started quickly with the API. See more examples.

html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \
    "http://www.example.com" > "example.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \
    "/path/to/MyLayout.html" > "MyLayout.pdf"
echo -n "<html><body><h1>Hello World!</h1></body></html>" | \
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" - > "HelloWorld.pdf"

API Playground Examples

The API can be easily integrated into your environment. You can have our interactive API Playground autogenerate the integration code for you:

Troubleshooting

  • Refer to the API Status Codes page if the API returns an error.
  • You can use -debug-log to get detailed info about the conversion, such as load errors, load times, browser console output, etc.
  • Check the FAQ.
  • You can use our JavaScript library to resolve rendering problems, such as missing content or blank pages.
    Just use -custom-javascript with libPdfcrowd.highlightHtmlElements method call to visualize all HTML elements. See the backgrounds example , borders example and helper JavaScript library documentation.
  • Contact us if you need help or missing a feature.