One of the necessary task in working with web pages is saving these pages in PDF format. We call it as html rendering.

Since web pages may contain texts, images, embedded fonts, hyperlinks, signatures etc, a reliable renderer must maintain layout in PDF format. Also a renderer shall convert a large number of web pages at once.

Web Renderer (WR) is a cloud service allows you to successfully, quickly and easily render your HTML documents into the PDF document or PNG image. Personally I’ve been actively using it for more than 10 years, thanks to reliability of service. WR provides both synchronous and asynchronous methods to developers. I strongly suggest using asynchronous approach due to nature of conversion lifecycle and to bypass connection timeout limitation of gateway platform.

Asynchronous approach is so simple to implement. You only need to send HTML content to SubmitPDFFromHTMLTask or SubmitImageFromHTMLTask API methods to receive task identifier as response. There is also SubmitPDFFromUrlTask and SubmitImageFromUrlTask methods to render PDF or Image from uri of web pages.

After receiving task identifier you need to check task status by calling GetRenderingTaskStatus method. You need to call same method after a few seconds delay as long as task status equals to “Waiting”. Once you receive “Completed” from GetRenderingTaskStatus method you can break loop and call DownloadResult method to download final file. Rendering workflow is illustrated in the diagram below.

Illustration 1: Rendering Workflow

Step 1. Obtain your token

To make the API calls, you need a valid access token. We will send access token in http headers. You may obtain your access token by creating app for cloud API.

Step 2. Implement and iterate asynchronous approach

WR accepts HTTP Form post requests. It was popular approach in early 2000s. Here I’ve listed client implementations in various programming languages.

How to Convert HTML to PDF by Using Python

How to Convert HTML to PDF by Using C#

How to Convert HTML to PDF by Using Java

How to Convert HTML to PDF by Using Visual Basic

How to Convert HTML to PDF by Using Go Lang