Generate a Blank PDF

This guide will take you through the process of generating a blank PDF using the PDF Generation feature.

Document Content

To generate a blank PDF, you can supply some HTML that renders as an empty page, like so:

<!DOCTYPE html>
<html>
</html>

PDF Generation

Next, send the above HTML to Document Engine for generation. Use the /api/documents endpoint, sending the PDF Generation schema with the HTML file from above:

curl -X POST http://localhost:5000/api/documents \
  -H 'Authorization: Token token=<API token>' \
  -F document_id=blank-document \
  -F generation='{ "html": "page.html" }' \
  -F page.html=@/path/to/page.html
POST /api/documents HTTP/1.1
Authorization: Token token=<API token>
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="document_id";

blank-document
--customboundary
Content-Disposition: form-data; name="generation";
Content-Type: application/json

{ "html": "page.html" }
--customboundary
Content-Disposition: form-data; name="page.html" filename="page.html";
Content-Type: text/html

<HTML data>
--customboundary

After performing the above curl command, you can view the generated document in the Server dashboard at http://localhost:5000/dashboard/documents/blank-document:

A blank PDF

Using the PDF Generation schema, you can control the page size you want to create. In this example, you create the page in letter size:

curl -X POST http://localhost:5000/api/documents \
  -H 'Authorization: Token token=<API token>' \
  -F document_id=blank-document \
  -F generation='{ "html": "page.html", "layout": { "size": "Letter"} }' \
  -F page.html=@/path/to/page.html
POST /api/documents HTTP/1.1
Authorization: Token token=<API token>
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="document_id";

blank-document
--customboundary
Content-Disposition: form-data; name="generation";
Content-Type: application/json

{ "html": "page.html", "layout": { "size": "Letter"} }
--customboundary
Content-Disposition: form-data; name="page.html" filename="page.html";
Content-Type: text/html

<HTML data>
--customboundary