Use CasesSeptember 23, 2026

Generate PDFs in n8n That Don't Break Across Pages

Pressa Team

n8n reads PDFs all day, but it cannot make one. Convert to File has no PDF output, and the most-read forum thread on the subject, How can I generate a PDF file with n8n? (35,000 views), still sends people to outside services.

Most of those services do one of two things: fill a Google Docs template and export it, or render HTML in a headless browser. Both work for a one-page receipt. They start to fail when the document gets long: an invoice with a variable number of line items, a table that spills onto the next page without its header row, a footer that lands in the middle of a row, an empty last page. Those complaints keep coming back on the n8n forum.

This guide shows a different route. Your workflow, or an AI node inside it, produces LaTeX. Pressa compiles it and returns a typeset PDF. LaTeX has handled page breaks, running headers and long tables for decades, and Pressa runs it for you, so there is nothing to install on your n8n server and it works the same on n8n Cloud.

What you need

  • A Pressa API key. It is free, takes about 30 seconds and needs no card: create one here.
  • Any n8n instance, Cloud or self-hosted. No community node and no extra software.

You can call the API without a key for a quick test (up to 3 pages, 3 PDFs a day), but use a key inside n8n. n8n Cloud sends requests from a shared pool of addresses, so keyless calls from every Cloud workflow count against the same anonymous limit.

Step 1: Store the key as a credential

In n8n, create a credential of type Header Auth. Set the name to X-API-Key and the value to your key. Referencing a credential keeps the key out of the workflow itself, so you can export or share the workflow without leaking it.

Step 2: Compile with an HTTP Request node

Add an HTTP Request node after whatever produces your document and set:

  • Method: POST
  • URL: https://api.pressa.dev/api/v1/compile
  • Authentication: Generic Credential Type, then Header Auth and the credential from step 1
  • Send Body: on, Body Content Type JSON, Specify Body Using Fields Below, one field named latex with the value {{ $json.latex }}

Using fields instead of a hand-written JSON body lets n8n escape the LaTeX for you; backslashes and quotes in the source would otherwise break the JSON. The request is the same as this curl call, which you can run from any terminal to check your key:

Terminal
curl -X POST https://api.pressa.dev/api/v1/compile \
-H "X-API-Key: pressa_your_key_here" \
-H "Content-Type: application/json" \
-d '{"latex":"\\documentclass{article}\\begin{document}Hello from n8n\\end{document}"}'

The response is JSON with a signed link to the PDF, the page count and the compile time:

response
{
"pdf_url": "https://api.pressa.dev/api/v1/pdfs/...",
"expires_at": "2026-09-24T18:02:11Z",
"pages": 2,
"compilation_time_ms": 842
}

Step 3: Turn the link into a file

Gmail, Google Drive and S3 nodes want the PDF as a file, not a link. Add a second HTTP Request node:

  • Method: GET, URL: {{ $json.pdf_url }}
  • Authentication: None. The link is signed, so it needs no key.
  • Options, Response, Response Format: File, with Put Output in Field set to data

The PDF is now binary data in the field "data", which is where Gmail attachments and Google Drive uploads look by default. Download it in the same run: links expire after 24 hours with a key and after 1 hour without one.

When the LaTeX is wrong

If the source does not compile, Pressa answers with HTTP 422 and a diagnosis written to be acted on, not a raw TeX log:

422 response
{
"error": "compilation_failed",
"message": "\badmacro is not a known command in this document.",
"diagnosis": {
"error_class": "undefined_command",
"suggested_fix": "Either \badmacro is misspelled, or the package that defines it is missing from the preamble. Check the spelling first, then add the appropriate \usepackage.",
"retryable": true
}
}

To branch on it in n8n, turn on Include Response Headers and Status and Never Error in the compile node's options. The response then arrives under body with a statusCode; route on the status code with an If node and hand body.diagnosis.suggested_fix back to your AI node for another attempt. Failed compiles do not count against your quota, so a retry costs nothing.

Or let an AI Agent write and fix the document

If an AI Agent node writes the document, skip the HTTP Request plumbing for the compile step. Attach an MCP Client Tool to the agent with Endpoint https://api.pressa.dev/mcp, Server Transport HTTP Streamable and Authentication Bearer Auth, using your key as the token. The agent writes the LaTeX, calls compile, reads the diagnosis and retries on its own, then answers with the PDF link. Pass that link to the download node from step 3. Setup details are in the MCP server docs.

Example: a tailored resume for every job posting

One of the most common reasons people generate PDFs in n8n is the job hunt: keep a resume, let an AI node adjust it to each job description, and email yourself the result. LaTeX is a natural fit, because the popular one-page resume templates are written in it.

  1. A Form Trigger or a Google Sheets row supplies the job description.
  2. An AI node rewrites the bullet points of your LaTeX resume for that posting and returns the full source, without Markdown fences around it.
  3. The compile and download steps above turn it into a PDF.
  4. A Gmail node sends it to you, or a Google Drive node files it next to the application.

A one- or two-page resume compiled with pdflatex fits comfortably in the free plan.

Limits

  • Without a key: pdflatex, up to 3 pages and 30 KB of LaTeX per document, no images, 3 successful PDFs a day.
  • With a free key: 50 PDFs a month, xelatex, images and 24-hour links.
  • Paid plans add saved templates, where your workflow sends only JSON data, plus the asset library and longer documents.

Everything else about the API is in the API reference. The MCP server, including the n8n settings above, is covered in the MCP server docs.

Try Pressa Free

One API call. LaTeX in, PDF out. Professional documents in seconds.