Include barcode font on pdf
-
Hi,
I have created a new template for packing-slip and included the barcode font (ttf format), and it shows fine in the HTML debug, but not in pdf version.Can you point me in the right direction about what could be wrong?
I have linked to a zipped version of the template on dropbox.
Notice – url to font is hardcoded in style.css (needs to be changed for you to test)
The page I need help with: [log in to see the link]
-
I haven’t looked at your zip yet, but you can’t load fonts remotely, here’s a guide that should help: https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-custom-fonts/
If you already followed that but it’s not showing, could you post the relevant CSS here?
/* BARCODE FONT */
@font-face {
font-family: ‘barcode’;
font-style: normal;
font-weight: normal;
src: local(‘barcode’), local(‘barcode’), url(https://www.ccf-test.dk/wp-content/themes/flatsome-child/woocommerce/pdf/CCF/fonts/barcode.ttf) format(‘truetype’);
}.barcode {
font-family: ‘barcode’;
}Site is running on ccf-test.dk FYI
As written in the documentation, you need to use the local path rather than the URL (and you won’t see the result in HTML unless you have installed the font on your computer).
Already tried that, does not make any change.
Still only shows on HTML debug, but not on pdf.“/wp-content/themes/flatsome-child/woocommerce/pdf/CCF/fonts/barcode.ttf”
That’s not the full path though, you need everything before /wp-content too, like so:
url(<?php echo $this->get_template_path(); ?>/fonts/barcode.ttf)Can you test with a regular/non-barcode font to make sure it’s not related to the font itself?
It shows correctly in HTML so path is right and I don’t have the font installed located.
The problem is that server side generation works different from local viewing. The PDF is created on the server and needs to read the complete path. As a result, the browser will not be able to find the font (since it cannot read files directly from the server), but the PDF can. So if you’re seeing the font loaded in the browser, it’s an indication that you haven’t used the correct path.
Can you use the aforementioned format and also test with a non-barcode font to make sure that it’s not a problem with the font (the PDF generator doesn’t play nice with all fonts).
That were it! Thank you for your help it works now! π
Glad to hear that π
When you say “that was it” – what exactly? The font or the path?The path π
Now I have a barcode on the picking-slip that can be used for pickingpal. Next mission is to add locations π
The topic ‘Include barcode font on pdf’ is closed to new replies.