PDF Create

Generate PDFs from HTML with basic CSS — fast, lightweight and easy to integrate.

Overview

Give Me PDF offers two API endpoints for converting HTML to PDF. This page covers the PDF Create endpoint.

Creating a PDF

Send a POST request to the following endpoint to generate a PDF:

POST https://www.givemepdf.com/api/v1/pdf/create

This endpoint supports PDFs with basic CSS features. If you need modern CSS features or complex layouts, use PDF Render.

Credits required: 2 / request

Authentication

Every API call must include an API-KEY header.

You can find your API key in your dashboard.

Request body

Requests must be sent as form-data and include a body parameter containing the HTML you want to convert.

You can also pass an optional document_name parameter (up to 60 characters) to help you identify your document.

PDFs use portrait orientation by default. For landscape, set the orientation parameter to landscape.

Parameter Accepted value Required
body HTML code or plain text Yes
document_name String, up to 60 characters No
orientation portrait (default) or landscape No

Response

When the conversion succeeds, you will receive a JSON response with status code 200 and a link to download your PDF. Here is a sample response:

{
    "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

Status Message How to fix it
401 Unauthorized API-KEY missing Make sure your request includes the API-KEY header with a value.
401 Unauthorized Invalid API Key Your API key is incorrect, expired or revoked. Sign in to your dashboard to copy a valid key or generate a new one.
429 Too Many Requests You have hit your account per minute request limit Each plan allows a limited number of requests per minute. Please wait a moment and try again.
429 Too Many Requests Monthly limit of x requests used up Free accounts include a fixed number of requests each month, and you have reached it. Your quota resets next month — Pro users do not have monthly limits.
422 Unprocessable Entity Missing body parameter in request Your form-data request is missing the body parameter.
422 Unprocessable Entity Missing HTML content for PDF generation Your request includes the body parameter, but it is empty. Send your HTML content in this parameter.
500 Internal Server Error PDF creation error Something went wrong while creating your PDF. Please check the troubleshooting tips below. If the problem persists, contact us. Contact us

Troubleshooting

  • Stick to basic HTML tags. Give Me PDF uses wkhtmltopdf, and anything that is not compatible with it may cause an error.
  • Always use absolute paths for images, because assets cannot be loaded from relative paths. For example, use <img src="https://example.com/images/cat.jpg"> instead of <img src="/images/cat.jpg">. The same applies to other assets, such as CSS files.
  • If you need relative paths in your HTML, add a base tag inside your head tag: <base href="https://www.example.com/">
  • If Unicode characters are not rendering correctly, add the following meta tag to your head: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> Still having trouble? Contact us and let us know which language you are trying to render.