A tutorial on our API that converts web pages to PDF in bulk

In this post I will discuss how you can convert web pages to PDFs using CronDock html2pdf mini app

In the previous article I discussed how you can convert web pages to images in bulk using CronDock html2img mini app. In this article, I want to talk about another API you can use to convert web pages to PDFs this time in bulk.

Using CronDock html2pdf RESTful API you can easily convert web pages to PDF in bulk. After signing up, CronDock web portal will provide you with an API key which can be used to call the CronDock RESTful API. Using the API key you can call CronDock via different tools such as "curl", python libraries (such as "requests") or tools such as postman .

CronDock API end point is https://api.crondock.com/. Keep in mind that in all your API calls to CronDock API endpoint, you should add your "API key" in a Header called "Authorization" and you need to add "Api-Key " at its begining. So for instance in "curl" you will have something like (replace XXXXX with your "API key"):

curl -X GET -H "Content-Type: application/json" -H "Authorization: Api-Key XXXXX" https://api.crondock.com/run/html2pdf/html2pdf-123456/
                

I am implementing different mini apps in CronDock that are accessible via the same api. The mini app for converting websites to PDF is called html2pdf and can be accessed via https://api.crondock.com/run/html2pdf/ endpoint. Using this mini app you basically can pass multiple urls and the api will provide you with links to download the PDF version of those websites. To do that, you need to make a POST request to https://api.crondock.com/run/html2pdf/ endpoint and provide the urls as a list to the request payload:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Api-Key XXXXX" -d '{
   "urls": ["https://google.com", "https://yahoo.com"]
}' https://api.crondock.com/run/html2pdf/
               

The response from the API will be something like below:

{"status": "OK", "job": "html2pdf-4yb4uz"}
              

The job name provided in the response can be used to pull the end results:

curl -X GET -k --url https://api.crondock.com/run/html2pdf/html2pdf-4yb4uz/ -H "Content-Type: application/json" -H "Authorization: Api-Key XXXXX"
               

The response will be something like:

{
  "status": "OK",
  "data": {
    "status": "Succeeded",
    "output": {
      "success": true,
      "data": [
        "https://crondock.s3.amazonaws.com/htmltoimage/8612481d-2816-4c17-ab32-40698d43ee18.pdf?AWSAccessKeyId=AKIAWCRKQQPUVELP5AGD&Signature=khZFxg2q0PqCTJe5LT57aeolZe4%3D&Expires=1664235952",
        "https://crondock.s3.amazonaws.com/htmltoimage/97f6e1ab-ca4a-4df6-8baf-2ff2d4f5c7cd.pdf?AWSAccessKeyId=AKIAWCRKQQPUVELP5AGD&Signature=DzodrnW%2B40KRFxY9whpEOtCfHzc%3D&Expires=1664235954"
        ]
      }
    }
}
               

In which you can find the download links to the PDFs.

Beside convering websites to PDFs, there are other things you can do with CronDock:

Using CronDock for converting webpages to images

Using CronDock for two-factor authentication

Or programmatically create cron jobs that run on a frequent basis

Or jobs that run at a specific time.

Or even jobs with dependencies.

Please let me know if you have any question at support@crondock.com

I also have a good document which provides more detailed information on all the requests you can make to CronDock API.