This FAQ refers to the plugin’s built in “simple” template. If using a PDF generated by another plugin (e.g. WP Overnight’s PDF Invoices and Packing Slips), then you need to follow their documentation instead.
In PDFs, standard Windows core fonts are available. Our plugin also adds Deja Vu, which has good UTF-8 coverage (which the Windows standard fonts don’t). But in case you want to import another font…
If you are printing the output of another plugin, then you will need to consult that plugin’s documentation for guidance on how to embed extra fonts into its output.
If using this plugin’s default template, then you can add extra fonts, like so:
- Log in to the shell on your webserver
- Navigate to the directory wp-content/plugins/woocommerce-printnode/vendor/dompdf/dompdf/lib/fonts
- Copy the font you wish to import, which must be in TrueType format, into this directory. Include bold and italic versions, if you intend to use them.
- Navigate to the base directory of the plugin, and run the script load_font.php in the “utils” directory (run “php utils/load_font.php” to show the syntax). Make sure that the font name matches the font name you will use in your template HTML.
Remember to use the CSS font-family selector where appropriate in your template HTML to actually select your chosen font.
Note that the above changes will be wiped out if/when you upgrade the plugin. To avoid this, after adding the font, you can copy the fonts directory (wp-content/plugins/woocommerce-printnode/vendor/dompdf/dompdf/lib/fonts) to a different directory on your webserver, and define the constant DOMPDF_FONT_DIR in your wp-config.php to point to your new directory.
e.g. if you copied it to the folder /home/myuser/public_html/dompdf-fonts, then you’d put:
define(‘DOMPDF_FONT_DIR’, ‘/home/myuser/public_html/dompdf-fonts’);