1. Documentation /
  2. PDF Invoices

PDF Invoices

PDF Invoices attaches a fully customizable PDF invoice to a paid or completed order and other WooCommerce emails.

Invoices can accessed via a Download Invoice link on the Thank You page or in the My Orders area and be resent by selecting Completed Order from the order actions meta box.

The layout of templates is fully customizable, and fields can be added or removed as needed.

Installation and Updating

↑ Back to top

For a new installation, review our extension installation guide

If you need to update the extension, you can do this from your WordPress Admin if you have connected the site to WooCommerce.com. More at: you can read more about that Managing WooCommerce.com Subscriptions.

You can also update manually by downloading the latest version from your WooCommerce account

Once you have the zip file downloaded you should deactivate and delete the existing version from your WordPress plugins page and then install the new version using the upload option. You will not lose any settings or data by updating this way.

Setup and Configuration

PDF Invoice settings can be found in the PDF Invoice menu which is located in the WooCommerce menu tab. Complete the settings form, there are tool tips (?) if you need more information on a setting.

It’s important to remember that an invoice is a legal document, and the format should be setup in line with the legal requirements of your local tax office.

Date Format

↑ Back to top

You can set the format of the invoice date, using standard PHP date functions: (http://php.net/manual/en/function.date.php)

An example of the chosen date format is shown in the PDF Invoice settings once saved.

Screen Shot 2013-07-08 at 09.03.58

Examples

  • d M Y : 08 Jul 2013
  • j F, Y : 8 July, 2013
  • d-m-y : 08-07-13

Testing Invoice Layouts

↑ Back to top

To test your layout and settings, create a test order and set it to completed.

All orders, completed or otherwise, will have a “Download Invoice” icon in the actions area:

Screen Shot 2013-07-06 at 12.41.53

Click and check the invoice layout.

PDF File Name Parameters

↑ Back to top

The PDF filename should be unique and easy to spot for customers. Use up to 3 variables and any other text. For example:

INVOICE {{company}}-{{invoicenumber}}-{{invoicedate}}

would give a file name of INVOICE-WooThemes-AAA1234BBB-12052013.pdf

You can arrange the variables in any order.

  • {{company}} : Your company name.
  • {{invoicedate}} : The invoice date.
  • {{invoicenumber}} : The invoice number.
  • {{ordernumber}} : The order number from the WooCommerce order.
  • {{month}} : The full month from the invoice date, eg March.
  • {{mon}} : The 3 letter month from the invoice date, eg Mar.
  • {{year}} : The year from the invoice date

There is also a filter that can be used to modify the file name further :

apply_filters( ‘pdf_output_filename’, $filename, $order_id );

PDF Invoice Number Suffix

↑ Back to top

If required, the invoice number suffix can include the current year. Add:

{{year}}

to the suffix setting.

Choosing which emails to attach an invoice to

↑ Back to top

From version 4.12.0 the option to choose which email has an invoice attached has moved to WooCommerce -> Settings -> Emails.

Each email now has an option to attach an invoice if an invoice is available.

Attach a PDF Invoice to this email

Create Invoices for Existing Orders

↑ Back to top

If you need to create an invoice for a previously completed order, just resend the Completed Order email from the Order Actions meta box.

Order Screen

↑ Back to top

Order Layout

↑ Back to top

The PDF invoice extension adds new features to the WooCommerce Orders screen.

Screen Shot 2013-07-06 at 12.41.53-1
  • Invoice number: Click to download an invoice to your computer.
  • Send invoice icon: Click to resend a Completed Order email to the customer
  • Download invoice icon: Click to download a copy of the invoice to your computer. This icon shows for all orders, completed or otherwise. If the order is incomplete, no invoice will be shown for the downloaded PDF.

By default the actions column is hidden by WooCommerce, you can enable it in Screen Options

Bulk Actions Drop Down Menu

↑ Back to top

If you need to modify the existing PDF Invoice information, for example if the wrong date is on the invoice or the format needs to be changed you can make changes with the “Update PDF Meta” option. It will only show if the debugging option has been set in PDF Invoice settings – Please ensure you are aware of any potential legal issues before using this option.. Ideally, make the necessary changes in your settings if required and then update one invoice to confirm that everything has worked correctly.

If you want to create invoices for some orders that do not already have an invoice number you can use the “Create and Email Invoice”. There is a filter available to prevent the email from being sent.

add_filter( 'pdf_invoice_bulk_send_invoice', 'remove_pdf_invoice_bulk_send_invoice' );
function remove_pdf_invoice_bulk_send_invoice() {
return false;
}
view raw gistfile1.txt hosted with ❤ by GitHub

This option will work for past orders, especially if the option in the settings is timing out.

Usage

↑ Back to top

A PDF will be attached to all Paid or Completed Order emails.

Customers can get a PDF invoice via a Download Invoice link on the Thank You page or access copies from their My Orders area.

You can also attach a PDF to the ‘New Order’ emails received by the store admin.

Customization

↑ Back to top

Copy the template to your theme

↑ Back to top

To customize the template, first create a copy in your theme.

wp-content/themes/YOUR_THEME/pdf_templates/template.php

If your server file permissions allow, you can create a copy of the PDF template by clicking the “Copy the PDF invoice template file into your template folder ready for customising.” link in the WooCommerce -> PDF Invoices -> Help and Customisation tab, shown here :

Once you have copied the template file to your theme folder you will be shown a link to go straight to the theme editor where you can begin making changes to your PDF Invoice template :

Add new placeholders

↑ Back to top

see Hooks and Filters in WooCommerce PDF Invoice for more information — and change the layout and move sections around.

Template files use HTML tables. This is a limitation of the DOMPDF library, in that some CSS classes can be used, but you’ll need to experiment to see which work and which don’t.

Using the included fonts

↑ Back to top
wp-content/plugins/woocommerce-pdf-invoice/lib/dompdf/lib/fonts/
wp-content/plugins/woocommerce-pdf-invoice/lib/dompdf/lib/fonts/dompdf_font_family_cache.dist.php

You can then change the font in the template.php file. If the font is not included with DOMPDF, you can use Google Fonts. Add a link to template.php and then add the style as you would in a normal HTML file.

Using Google Fonts

↑ Back to top

Get the font url from Google (https://fonts.google.com) and then modify the template as follows. It is important that your font contains all of the necessary characters for your language and it should also contain enough styles for normal, bold, H1, H2.

    @import url('https://fonts.googleapis.com/css?family=Orbitron');

    body {
      font-family: 'Orbitron', sans-serif, "DejaVu Sans Mono", sans-serif, monospace;
      font-size:11px;
    }

Using a True Type font

↑ Back to top

Make sure you know the location of the font and then modify the template as follows. It is important that your font contains all of the necessary characters for your language and it should also contain enough styles for normal, bold, H1, H2.

    @font-face {
      font-family: 'Firefly';
      font-style: normal;
      font-weight: normal;
      src: url(http://example.com/fonts/firefly.ttf) format('truetype');
    }
    body {
      font-family: 'Orbitron', sans-serif, "DejaVu Sans Mono", sans-serif, monospace;
      font-size:11px;
    }

Adding background colour to the PDF product lines

↑ Back to top

Requires PDF Invoices 4.4.5

Add the following CSS to your PDF template, the template contains all of the possible class names

.orderdetails {
border-collapse:collapse;
}
.ordercontent {
border-collapse:collapse;
}
.pdf_table_row_heading {
color: #FFF;
background-color:#000;
}
.pdf_table_cell_heading {
padding: 4px 0;
}
.pdf_table_row_even {
background: #CACACA;
}
view raw gistfile1.txt hosted with ❤ by GitHub

For reference, this is an example HTML output of the product section before the PDF is created

Using Hooks and Filters

↑ Back to top

For more information on hooks and filters in WooCommerce PDF Invoice, see: Hooks and Filters in WooCommerce PDF Invoice.

Translating PDF Invoice

↑ Back to top

You can use the free Loco Translate plugin to translate any or all of of the strings in PDF Invoice. If you only want to change two or three strings, then the Say What? free plugin may be better suited. (Use the domain: woocommerce-pdf-invoice)

If you use Loco Translate and keep custom translations in woocommerce-pdf-invoice/languages, they can be lost when upgrading. To keep them upgrade safe, place them in wp-content/languages/woocommerce-pdf-invoice/

FAQ

↑ Back to top

Are PDFs stored in a secure way?

↑ Back to top

PDFs are created as needed and stored in your hosting tmp folder, which isn’t typically accessible from a browser. A CRON task deletes PDFs every half hour to avoid filling up your server.

Missing Logo?

↑ Back to top

As part of the update to version 4.12, the DOMPDF PDF generator was updated for PHP 8. Included in this update a bug was fixed that allowed files not included in the PDF Invoices plugin folder to be included in the PDF, logos for example.

As of version 4.12.2 there is a new option, “Set Resources Folder”, to set the “allowed directory” to the site wp-content directory. This change will allow the PDF to include files that are anywhere within the site wp-content directory.

If your logo is missing from the invoice then you can set the “Set Resources Folder” option to “Yes” in the PDF Invoices settings.

If you have set the “Remote Logo” option to yes because your logo was missing from the invoice then you can revert this back to “No” once you have set the “Set Resources Folder” option to “Yes”.

Bulk Exporting PDFs

↑ Back to top

From version 4.0.0 of WooCommerce PDF Invoice there is an ability for store owners to create a zip file of several invoices. This is version 1 of bulk exporting. Future releases of WooCommerce PDF Invoice will improve on this, based on feedback from store owners. Please email any ideas or feedback to plugins@chromeorange.co.uk

To export several PDFs, view your order list, select the orders you want the PDFs for, choose “Bulk Export PDFs” from the “Bulk Actions” drop down and click “Apply”. Once the zip file is available there will be a link to download it.

bulk export pdfs

Editing invoices

↑ Back to top

From version 4.2.0 of PDF Invoices it is possible to modify previously uneditable invoice data.

To access this the PDF debugging option should be set to yes. Once that is done edit the order that needs to be modified and look for the Invoice meta box, usually at the bottom of the page.

Before making any changes here you should be aware of any legal issues that may occur if you modify an invoice that has already been issued to a customer, if you are not sure please consult your accountant.

Feedback and feature requests

↑ Back to top

For feedback on the PDF Invoice extension, this documentation or for feature requests please email plugins@chromeorange.co.uk

Questions & Support

↑ Back to top

Have a question before you buy? Please fill out this pre-sales form.

Already purchased and need some assistance? Get in touch the developer via the Help Desk.