Skip to main content
This feature is only available in the Enterprise plan. Contact our sales team at sales@fynn.eu for more information.

Overview

With Custom PDF Rendering, you can use your own PDF rendering engine to generate invoices, credit notes, and cancellations according to your individual requirements. This enables:
  • Complete Design Control: Design documents exactly according to your corporate design guidelines
  • Custom Template Engines: Use your preferred template engine (LaTeX, Typst, etc.)
  • Complex Layouts: Create multi-page documents with complex tables and graphics
  • Integration with Existing Systems: Seamlessly integrate your existing document generation

How It Works

  1. Document is finalized: When a document is finalized, it transitions to STATUS_FINALIZING status
  2. Webhook is triggered: Fynn sends the invoice.pdf.generation_requested webhook with all document data
  3. Generate PDF: Your system generates the PDF with your own rendering engine
  4. Upload PDF: The finished PDF is sent back to Fynn via the API
  5. Complete finalization: Fynn completes the finalization process (ZUGFeRD embedding, sending, etc.)

Configuration

1. Enable Feature

Contact Fynn support to enable the feature for your organization.

2. Register Webhook

Register a webhook for the invoice.pdf.generation_requested event:
1

Open Webhooks

Navigate to Settings > Webhooks
2

Create New Webhook

Click New Webhook and configure:
  • URL: The URL of your webhook endpoint
  • Events: Select invoice.pdf.generation_requested
  • Secret: A secure secret for signature validation

3. Configure Settings

Under Settings > Billing > Custom PDF Rendering you can configure the following options:
Custom PDF Rendering Settings

Webhook Payload

The invoice.pdf.generation_requested webhook contains all document data:

Upload PDF

After PDF generation, the document must be uploaded via the API:

Endpoint Details

Request

  • Content-Type: multipart/form-data
  • Field: file - The PDF file (MIME type: application/pdf)

Response

200 OK

Error Codes

Timeout and Fallback

When Custom PDF Rendering is enabled, Fynn waits for the PDF to be uploaded. If the PDF is not uploaded in time:
  • With fallback enabled: After the timeout expires, Fynn automatically generates the PDF with the internal rendering engine
  • Without fallback: The document remains in STATUS_FINALIZING status until the PDF is manually uploaded
Ensure your system uploads the PDF within the configured timeout to avoid delays in document processing.

ZUGFeRD Embedding

When embedZugferd is enabled, Fynn automatically embeds the ZUGFeRD/Factur-X XML data into the uploaded PDF. This ensures compliance with the German e-invoicing standard.
You don’t need to handle ZUGFeRD generation – Fynn handles the embedding automatically after upload.

Best Practices

Webhook Processing

  1. Asynchronous Processing: Acknowledge the webhook immediately (HTTP 200) and process PDF generation asynchronously
  2. Idempotency: Implement idempotency to handle duplicate webhook calls
  3. Retry Logic: Implement retries for PDF upload on temporary failures

PDF Requirements

  • Format: PDF/A-3 is recommended for best ZUGFeRD compatibility
  • Size: Maximum 10 MB
  • Quality: At least 150 DPI for embedded images

Security

  • Validate the webhook signature
  • Use HTTPS for all API calls
  • Store API tokens securely

Example Implementation (Node.js)

Troubleshooting

PDF Not Accepted

  • Ensure the file is a valid PDF
  • Check that the document is in STATUS_FINALIZING status
  • Validate that you’re using the correct invoice ID

Webhook Not Received

  • Check that the webhook is registered for invoice.pdf.generation_requested
  • Ensure your endpoint is reachable
  • Check the webhook logs in Fynn settings

Timeout Errors

  • Increase the timeoutMinutes value
  • Optimize your PDF generation
  • Enable fallback for critical situations

API Reference

For more details on the API, see the API documentation.