Behaviour + facade for PDF rendering.
You rarely call this module directly. The typical entry point is
Accrue.Invoices.render_invoice_pdf/2, which renders an invoice to HTML
and then calls Accrue.PDF.render/2 under the hood. You interact with
this module mainly through two concerns:
- Adapter configuration — choose which backend renders PDFs.
- Test setup — swap in
Accrue.PDF.Testso your test suite does not require a Chrome binary.
Adapters
Accrue.PDF.ChromicPDF— production default. Delegates to the host application's ChromicPDF instance. Accrue does NOT start ChromicPDF — the host app must add it to its own supervision tree.Accrue.PDF.Test— Chrome-free test adapter. Sends{:pdf_rendered, html, opts}toself()and returns{:ok, "%PDF-TEST"}. Use in tests to avoid the Chrome binary dependency in CI.
Telemetry
[:accrue, :pdf, :render, :start | :stop | :exception] is emitted with
metadata %{size, archival, adapter}. The HTML body is NEVER placed in
metadata — it may contain PII.
Summary
Functions
Renders html to a PDF binary via the configured adapter.
Types
Callbacks
Functions
Renders html to a PDF binary via the configured adapter.
Options
:size— paper size (atom or tuple, adapter-specific). Default:a4.:archival— whentrue, produces PDF/A (long-term archival format). ChromicPDF usesprint_to_pdfa/1in this case.:header_html,:footer_html— optional header/footer HTML. The ChromicPDF adapter translates these to the:header/:footerkeys thatChromicPDF.Template.source_and_options/1expects.