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
(opens in a new tab) 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.1Authorization: Token token=<API token>Content-Type: multipart/form-data; boundary=customboundary
--customboundaryContent-Disposition: form-data; name="document_id";
blank-document--customboundaryContent-Disposition: form-data; name="generation";Content-Type: application/json
{ "html": "page.html" }--customboundaryContent-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:
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.1Authorization: Token token=<API token>Content-Type: multipart/form-data; boundary=customboundary
--customboundaryContent-Disposition: form-data; name="document_id";
blank-document--customboundaryContent-Disposition: form-data; name="generation";Content-Type: application/json
{ "html": "page.html", "layout": { "size": "Letter"} }--customboundaryContent-Disposition: form-data; name="page.html" filename="page.html";Content-Type: text/html
<HTML data>--customboundary