Customize the templates PDF Invoices uses to render order PDFs. The styling examples here use the Dompdf renderer. Test them on a store with fictional orders before using them on issued invoices.
Note:
This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.
Copy the invoice template
↑ Back to topCopy templates/template.php from the PDF Invoices extension into the active child theme as pdf_templates/template.php. Keep a copy of your changes so you can compare them with the extension’s template after an update. When you configure a different template for an email, the extension looks for the matching file in the theme.
Add the styles below to the template’s style element. Open a sample invoice with the layout you changed and verify it still shows all invoice data.
Customize template placeholders
↑ Back to topPlaceholders such as [[PDFCOMPANYNAME]] and [[PDFINVOICENUM]] are replaced when the PDF is generated. Keep the placeholder names intact when moving sections. [[ORDERINFOHEADER]] and [[ORDERINFO]] render the product table headings and rows.
See the existing PDF Invoices hooks and filters reference for more placeholders. To change generated file names in code, the pdf_output_filename filter receives the filename and the order ID. For most naming changes, use the invoice file name format setting.
Choose fonts for Dompdf
↑ Back to topUse a bundled font with the characters your invoices need. For example, set font-family to DejaVu Sans.
body {
font-family: 'DejaVu Sans', sans-serif;
}
For a licensed TrueType font, place the file in a local directory the renderer can read and reference it in an @font-face rule. Keep the font family in that rule consistent with the template’s font-family declaration. Verify the result in the PDF, including symbols and bold text.
Add a background color to product rows
↑ Back to topThe product table uses pdf_table_row_heading for its heading and pdf_table_row_even for alternate rows. Add this CSS to the copied template and render an invoice with at least two products.
.pdf_table_row_heading th {
background-color: #1f2937;
color: #ffffff;
}
.pdf_table_row_even td {
background-color: #eaf2f8;
}
If you supply styles from a site plugin instead, the pdf_template_additional_template_css filter replaces [[PDFINVOICEADDITIONALCSS]] in the default template. Return CSS and preserve any styles already supplied by another callback.
Questions and support
↑ Back to topSomething missing from this documentation? Still have questions and need assistance?
- If you have a question about a specific extension or theme you’d like to purchase, contact us to get answers.
- If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.