HTML to PDF

CustomJS provides powerful PDF generation capabilities that allow you to create professional PDF documents directly from your Make.com workflows. You can generate PDFs from HTML content, templates, or dynamic data.

Make.com PDF Generation
Make.com PDF Generation

How it works

The PDF generation module uses Chromium-based rendering for PDF generation, which means:

  • Consistent formatting across browsers
  • Full CSS support (including print media queries)
  • Complex layouts with headers, footers, and pagination
  • Output as binary or Base64

Key features

  • HTML to PDF conversion with full CSS support
  • Custom page formatting (A4, Letter, Legal, custom sizes)
  • Headers and footers with dynamic content
  • Page numbering and metadata
  • Print-friendly styling with media queries

Simple HTML to PDF

<h1>Hello World</h1>

Output

The module returns a binary file buffer that can be directly used with other Make.com modules like Google Drive, Dropbox, or email attachments.

You can directly access input field values using the 'input' JavaScript variable, or construct JSON objects for complex cases, as detailed in our JSON Parameter guide.

Screenshots

Make.com PDF Generation
Make.com PDF Generation
Make.com PDF GenerationOutput
Make.com PDF GenerationOutput

Advanced PDF Features

📦 Using External JavaScript Libraries (QR Codes)

You can use external JavaScript libraries like QRCode.js in your PDF templates. When using ES Modules, wrap your import in a module script tag:

<script type="module">
  import QRCode from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';

  // Generate QR code
  const qrDataUrl = await QRCode.toDataURL('https://example.com', {
    width: 150,
    margin: 1
  });

  // Set the image source
  document.getElementById('qr').src = qrDataUrl;
</script>

<img id="qr" alt="QR Code" />

→ Read the complete QR Code guide

⏱️ Async Rendering with window.__RENDER_DONE__

When using asynchronous JavaScript (QR codes, charts, API calls), you must signal when your content is ready by setting window.__RENDER_DONE__ = true. The PDF generator waits for this flag before capturing the page.

<script type="module">
  import QRCode from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';

  // Initialize as false
  window.__RENDER_DONE__ = false;

  async function generateQR() {
    // Your async operations
    const qrDataUrl = await QRCode.toDataURL('https://example.com');
    document.getElementById('qr').src = qrDataUrl;

    // Signal that rendering is complete
    window.__RENDER_DONE__ = true;
  }

  // Start generation
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', generateQR);
  } else {
    generateQR();
  }
</script>

⚠️ Important: Without setting window.__RENDER_DONE__ = true, your PDF may be blank or incomplete because the generator won't wait for async operations to finish!