HTML to Image in Command Line

This page describes how to convert web pages and HTML to images from the command line using the Pdfcrowd API.

Samples

Installation

Install the application from PyPI
pip install pdfcrowd

We also offer other installation options.

Authentication

Authentication is needed in order to use the Pdfcrowd API. The credentials used for accessing the API are your Pdfcrowd username and the API key.

You can try out the API without registration 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

Enter a web page or upload an HTML file to get an image preview and integration 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. You can also interactively explore the API in the API Playground.

Examples

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

Integration Examples

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

Troubleshooting

  • List of API Status Codes if an error code is returned.
  • You can use -debug-log to get detailed info about the conversion, such as conversion errors, time, console output.
  • 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.
  • The maximum size of the created image is 65 megapixels. Larger images are cropped vertically.
  • Take a look at the FAQ section.
  • Are you missing a feature? Contact us, we look forward to your suggestions.

User Manual

Refer for details to the User Manual.