Documentation

Generate complex PDF documents with custom layouts, styling, and components

HTML to PDF generation API

Give Me PDF provides few API endpoint to convert your HTML to PDF.

Rendering PDF

Send a POST request to https://www.givemepdf.com/api/v1/pdf/render endpoint to generate PDF. This endpoint support generation of PDF with advance and modern CSS features. If you want to use modern CSS features and generate complex layout in PDF, This endpoint is for you. Please use PDF create for simple HTML and CSS.

Credit Required: 3 / request

Authentication

All API call to create PDF from HTML must have API-KEY parameter on its header.

You can find your API key here.

Request Body

All request must be a form-data and should have parameter body whose value must contain your HTML code which will be converted to PDF.

You can also pass optional parameter document_name with maximum character limit of 60. You can use this parameter to easily identify your document.

For PDF orientation, application will use portrait by default but if you want your PDF in landscape mode, use orientation parameter with value landscape.

Parameter Name Accepted Value Required
body HTML code or plain text Yes
document_name String with maximum of 60 characters No
orientation Valid values include portrait (default) or landscape No
scale Valid values include number range between 0.1 - 2.0 No (default: 0.75)
format Valid values include Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6 No (default A4) (Only Pro user can set other options)
Response

If HTML to PDF conversion was successful, you will receive JSON response with status code 200 containing link to download generated PDF. Sample response can be found below.

{
    "message": "OK",
    "data": {
        "location": "https://givemepdf.com/storage/8b6293cb05ee815c/ossrPslsisxeRLp0.pdf",
        "file_ttl_days": 1,
        "warning": "This file is available for limited time. Please download as soon as possible."
    },
    "meta": {
        "remaining_free_credit": 3470,
        "remaining_paid_credit": 10000
    }
}
Possible errors
Error Message Solution
401 Unauthorized API-KEY missing Make sure that your request header has API-KEY header with value.
401 Unauthorized Invalid API Key Your API key is either wrong, expired or revoked. Login to your dashboard to get valid API key or generate new one.
429 Too Many Requests You have hit your account per minute request limit We only allow limited requests per minute. You have exceeded this limit
429 Too Many Requests Monthly limit of x requests used up We only allow fixed number of requests per month for free account. You have reached this limit. Your quota will be reset next month. Pro users don't have monthly limits.
422 Unprocessable Entity Missing body parameter in request Your form-data is missing body parameter in request.
422 Unprocessable Entity Missing HTML content for PDF generation Your form-data has body parameter but its value is empty. You should send HTML content in this parameter.
422 Unprocessable Entity Missing HTML content for PDF generation Your form-data has body parameter but its value is empty. You should send HTML content in this parameter.
500 Internal Server Error PDF creation error Something went wrong while creating PDF from HTML. Please refer to our troubleshooting section for more detail. If all troubleshooting measures fail, please contact us.
Troubleshooting
  • You can use Javascript as Give me PDF uses puppeteer under the hood. However JS error in your HTML might result in error resulting in no PDF creation or broken PDF design.
  • Always try to use absolute path for images as its impossible to get images from relative path.
    Example use <img src="https://example.com/images/cat.jpg"> and not <img src="/images/cat.jpg"> Same applies for other assets like CSS.
  • If your have to use relative path in HTML, don't forget to add base tag on head tag.
    <base href="https://www.example.com/">
  • If you have trouble with rendering Unicode characters, please add proper meta tag on header.
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    If you still have problem with unicode rendering please contact us about the language you are trying to render.