For the complete documentation index, see llms.txt. This page is also available as Markdown.

DocRaptor

DocRaptor is a document generation service that converts HTML or XML content into PDF or Excel files. Use it in your workflows to programmatically generate invoices, reports, contracts, or any formatted document — and get back a download link instantly.

You can try DocRaptor without an account using the public test key YOUR_API_KEY_HERE. Documents generated with this key are always watermarked (a "TEST" stamp overlaid on every page). To generate production documents without a watermark, you need a DocRaptor account and a real API key from docraptor.com.

Test mode and quota

You can start building and testing your workflow without a DocRaptor account. Use the public test key YOUR_API_KEY_HERE in your connection — no sign-up required. Documents generated this way are always watermarked (a "TEST" stamp overlaid on every page) and, for Excel files, are limited to a small number of rows, but are otherwise fully functional for development purposes.

Once you are happy with your workflow and ready to go to production, create a DocRaptor account, replace the test key with your real API key, and switch Test mode to Off. From that point your documents will be clean and unbranded, and each run will consume your DocRaptor plan quota.

Setting Up the Connection

  1. In Stack AI, navigate to the Connections page.

  2. Click Add Connection and select DocRaptor.

  3. Enter your API key:

    • To test without an account, use YOUR_API_KEY_HERE

    • For production use, log in at docraptor.com/login and copy your API key from the dashboard

  4. Click Save.

Available Actions

Create Document

Converts HTML or XML content into a PDF or Excel file and returns a download URL.

Inputs:

Parameter
Type
Required
Description

Test mode

Select

Yes

On generates a free document (does not count against your key quota) with a "TEST" watermark on every page; Off generates a clean production document and uses your quota

Document content

Text

Yes

The HTML (for PDF) or XML (for Excel) content to convert

File type

Select

Yes

Output format: pdf, xls, or xlsx

File Name

Text

No

Optional name for the document, used in DocRaptor logs and as the filename

Outputs:

Field
Type
Description

download_url

String

Pre-signed URL to download the generated file

expiration_date

DateTime

When the download URL expires

file_metadata.filename

String

Name of the generated file

file_metadata.mime_type

String

MIME type of the file

file_metadata.bytes

Integer

File size in bytes

file_metadata.created_at

DateTime

When the file was created

Keep Test mode set to On while building your workflow. Switch to Off only when you are ready to generate production documents — production runs consume your DocRaptor quota.

Structuring your HTML for PDF output

In a typical Stack AI workflow, an LLM node generates the HTML that gets passed to DocRaptor. To get a well-structured PDF with headers, footers, and logos, include the formatting requirements directly in your prompt to the model. For example:

"Generate an HTML invoice for the following data. Include a <header> with the company logo at https://your-cdn.com/logo.png and the invoice number, a <footer> with the company address, and a <table> with a <thead> for the line items. Use inline CSS with position: running(header) and position: running(footer) so they repeat on every page. All image URLs must be absolute."

DocRaptor uses the Prince XML engine to render HTML into PDF. It supports standard HTML and CSS, plus a few Prince-specific CSS properties that control page layout. The key concept is running elements — HTML elements that are pinned to the top or bottom margin of every page, which is how you get repeating headers and footers.

Page layout with @page

Use the CSS @page rule to define the paper size and margins. Set the top and bottom margins large enough to accommodate your header and footer, then place your running elements in those margin boxes:

Mark any HTML element as a running header by setting position: running(header) in CSS. Everything inside it — logo, company name, invoice number — will repeat on every page:

Same pattern for the footer:

Repeating table headers across pages

If your content includes a table that spans multiple pages, use <thead> — Prince will automatically repeat it at the top of each page:

When passing HTML to the Create Document node, make sure any images or fonts are referenced via absolute URLs (e.g. https://...). DocRaptor fetches these remotely at render time — relative paths will not resolve.

Examples

Connect an LLM node to generate HTML content, then pass the output into the DocRaptor Create Document node to produce a formatted PDF. The download_url output can be passed to a subsequent node to send the file via email or post it to Slack.

Last updated

Was this helpful?