DocRaptor
Use DocRaptor for MainSDK PDF rendering - hosted HTML to PDF, setup, main.yaml, test documents and swapping from the built-in renderer.
DocRaptor is a hosted service that turns HTML and CSS into PDF documents. The docraptor driver behind pdf renders your templates there instead of in the built-in renderer. Pick it when your documents need print layout features the built-in renderer doesn't cover.
Interfaces it serves
Pick DocRaptor in main.yaml for any of these. Your calls stay the same, and you can swap later.
pdfPreviewDriver docraptor DocRaptor
pdf:
driver: docraptorBefore you start
- Create a DocRaptor account and copy its API key.
- Store the key in your secrets manager.
Configure
pdf:
driver: docraptorHosted pdf drivers take their keys as secret: references (for example secret:DOCRAPTOR_API_KEY); the key field name is not defined yet.
Use it
import { pdf } from "mainsdk";
export async function invoiceFor(order: { id: string }, user: { locale: string }) {
return pdf.render("invoice", { order, locale: user.locale });
}Local development and testing
pdf is phase 1, so createTestApp() from @mainsdk/testing renders on its in-memory fake with no hosted service. DocRaptor offers watermarked test documents for trying real renders. chaos.on("pdf", { outage: true }) simulates DocRaptor being down.
What MainSDK adds on top
- Text, money and dates localised through
i18n; a missing translation fails thei18ncheck, not the reader. - The same
pdf.render()call on every driver.
See PDF documents.
Limits and notes
pdfhas no spec; the DocRaptor driver is listed in the catalog and requirements.- DocRaptor receives the document data, which often holds personal data. Check its regions against your MainSDK data region (US, EU or India).
- Store generated documents through
files, not in DocRaptor.
Swap to or from it
pdf:
driver: docraptor # was builtinRendering holds no state, but whether templates need changes between renderers is still open.
FAQ
Do I need DocRaptor to render PDFs? No. The built-in renderer is the default.
Next
Open questions
Was this page helpful?