An event registration form that generates a professional-looking ticket/confirmation PDF. The document will have an elegant header, footer with page numbers, two-column layouts, and visual separators.
Real-world use case: A conference attendee registers online and receives a beautifully formatted PDF ticket they can print or show on their phone at the check-in desk.
addPageBreak()addRow() and multiple addField() callsaddDivider() for horizontal linesaddSpacer()pageSize: 'A4' | 'Letter')Every code snippet below is fully editable! Feel free to modify the code, experiment with different values, and see your changes reflected instantly in the live preview on the right.
Use the play button to run different snippets, or the refresh button to restore the original example.
Every professional document starts with a strong header. Add a title for the event name and a subtitle to clarify what this document is.
title for your brand or event name, and subtitle for context like "Registration Confirmation" or "Invoice #12345". For longer documents, you can split content across multiple pages. Use addPageBreak() to start a new page.
pdf.addPageBreak() between sections to force content onto a new page. This is useful for separating different types of information - like attendee details on page 1 and ticket details on page 2. Now that we have multiple pages, let's add a footer with automatic page numbering.
showPageNumbers: true to automatically add "Page 1 of 2" style numbering. The footer text is great for contact info, disclaimers, or reference numbers. Make your PDF more compact and professional by placing two fields side by side. Simply call addField() twice within the same addRow().
addRow(), they appear side by side in columns. Use dropdown.value() to get the selected value. Add visual polish with dividers and spacers. addDivider() creates a horizontal line, and addSpacer() adds vertical space.
addSpacer(10) to add 10 pixels of vertical space. You can also call addSpacer() without a parameter for default spacing. Combine dividers and spacers to create clear visual sections. Add the finishing touches: set the page size to A4 and customize the download button text to match your use case.
pageSize: 'A4' for international standard or 'Letter' for US standard. The downloadButtonLabel should tell users exactly what they're getting - "Download Your Ticket" is clearer than just "Download PDF". addText()Your PDFs now look professional! In the next tutorial, you'll learn how to add tables and summaries - perfect for order confirmations and invoices.
Continue to Tables & SummariesKey concepts learned:
header with title and subtitle - Professional document headersaddPageBreak() - Creating multi-page documentsfooter with text and showPageNumbers - Footers with page numbersaddField() in one addRow() - Column layoutsaddDivider() and addSpacer(height) - Visual separationpageSize and downloadButtonLabel - Configuration options