• Resolved muxus

    (@muxus)


    Hello,

    I use so-called non-breaking hyphens in my product descriptions. While being properly displayed in HTML (including emails), they aren’t shown correctly in the generated PDF invoices.

    For example: “Excel?Tool” (HTML) turns into something like “Excel[]Tool” (PDF).

    Is there a way to solve this problem?

    Many thanks and kind regards,
    Muxus

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter muxus

    (@muxus)

    P.S.
    In the meantime, I discovered that the problem is apparently caused by the embedded fonts:
    If I open the PDF file (generated without font subsetting) in Adobe Acrobat, select the text Touch-Up tool, select the words or characters in question, and change the font (e.g. to DejaVuSansCondensed/DejaVuSansCondensed-Bold) by using the context menu (right-click ==> properties), all the characters are shown correctly.
    Hence, would it be possible to allow for an alternative font in the plugin’s general settings?

    Plugin Contributor Ewout

    (@pomegranate)

    This is indeed most likely a character that is missing from the Open Sans character set. You could either replace the hyphen with a regular hyphen in the PDF using this code snippet:

    
    add_action( 'wpo_wcpdf_get_html', 'wpo_wcpdf_replace_hyphen', 10, 2 );
    function wpo_wcpdf_replace_hyphen( $html, $document ) {
    	$html = str_replace(array('?',"‑"), '-', $html);
    	return $html;
    }
    

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Or use a custom font: https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-custom-fonts/

    edit: it looks like www.remarpro.com filtered my html code for the non-breaking hyphen from the snippet, so I’ve pasted a copy here: https://pastebin.com/sT2g74Rm

    • This reply was modified 5 years, 2 months ago by Ewout.
    Thread Starter muxus

    (@muxus)

    Thank you very much!
    The snippet solution (https://pastebin.com/sT2g74Rm) is working perfectly fine!

    • This reply was modified 5 years, 2 months ago by muxus.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Non-Breaking Hyphens Not Shown in PDF’ is closed to new replies.