▫️HTML to PDF

Converts HTML content to a PDF document and uploads it to a file hosting service.

/html-to-pdf

This endpoint converts HTML content or a webpage to a PDF file. It supports converting either a URL or raw HTML content. The endpoint uses Puppeteer to render the webpage and generate the PDF. If upload is set to "Yes", the generated PDF will be uploaded to a file-sharing service, and the response will contain a download link. If upload is set to "No", the generated PDF will be returned directly as the response. Any errors during the conversion process will result in an appropriate error response with a status code of 500.

Request Body (htmlContent OR url)

This endpoint accepts a form-data body with the following fields:

  • url: (string) The URL of the webpage to convert to PDF.

  • htmlContent: (string) The raw HTML content to convert to PDF.

  • upload: (string) Specifies whether to upload the generated PDF or not. Possible values are "Yes" or "No".

Example:

{
    "htmlContent": "<!DOCTYPE html><html><head><title>My HTML to PDF</title></head><body><h1>Hello, World!</h1></body></html>"
}
{
    "url": "http://api.ziomark.xyz/"
}

With the "url" method, you cannot download heavy pages, otherwise the call will timeout

Response

Upon successful conversion and upload, the endpoint responds with the URL to the uploaded PDF document.

Example:

{
    "download_link": "https://file.io/abc123"
}

Note: The files is limited to maximum 1 download and will be deleted after

Error Responses

  • Status Code: 500 Internal Server Error

    • Body: "Error converting HTML to PDF"

    • Description: Occurs if there's an error during the conversion process.

Last updated