VirtueMart Forum

VirtueMart 2 + 3 + 4 => FAQ Frequently Asked Questions => Topic started by: Artanis on March 18, 2012, 19:09:37 PM

Title: [SOLVED] UTF-8 support in PDF Invoice
Post by: Artanis on March 18, 2012, 19:09:37 PM
[The whole thread is completly outdated, anything is now implemented as options]

Hello!

I have problem with PDF generatinon functionality in VM2. In my native Latvian language there are some non-latin symbols (e.g. "āūšļķž"), and some products in my shop have russian names using crylic (e.g. "название"), and when it comes to PDF invoice generation functionality in VM2, there are question marks "?" instead of these symbols in text. It's kind of not SO big deal, but it's still looks very unprofessional and crappy, and I'd like to correct this.

So, the question is - what can I do to correct PDF generation process to support UTF-8 characters? Add some kind of other fonts? Correct generation script? What?

EDIT: After googling a bit more, I think I found the solution (http://stackoverflow.com/questions/5333702/tcpdf-utf-8-problem). I'll check this out and notify here.

Thanks in advance, guys. I appreciate any help.
Best regards, Arthur.
Title: Re: UTF-8 support in PDF Invoice?
Post by: Artanis on March 18, 2012, 19:45:41 PM
This solution worked for me like a charm - Latvian ar Russian crylic characters now are displayed well!

Quote from: TheHostDogs on March 18, 2012, 19:39:46 PM
1. Download tcpdf from this link http://sourceforge.net/projects/tcpdf/
2. Take the fonts files included in the Fonts folder of the downloaded file and I copy them to the /libraries/tcpdf/fonts
3. Open /libraries/joomla/document/pdf/fonts.php and find the line where $pdf->SetFont is written (about line 221)
4. Replace the line with something like that $pdf->SetFont('freesans', '', 6, '', 'false');
5. Find "var $_header_font" and "var $_footer_font" (about lines 32 and 33) and replace the fonts there with freesans font:
   var $_header_font = 'freesans';
   var $_footer_font = 'freesans';

Maybe someone of administrators could pin this to FAQ? It's kind of must-have for non-english country users.
Title: Re: UTF-8 support in PDF Invoice
Post by: jenkinhill on March 18, 2012, 23:18:34 PM
Thank you for this.
Title: Re: UTF-8 support in PDF Invoice
Post by: bytelord on October 25, 2012, 19:35:51 PM
Also:

When order status updated from the backend or pdf invoice saved in safepath, controller runs a function that set the fonts again. So edit the file joomla_folder\components\com_virtuemart\controller\invoice.php

around lines 151, 152 change the font

$pdf->setHeaderFont(Array('freesans', '', 8 ));
$pdf->setFooterFont(Array('freesans', '', 10 ));

also around line 179, change also the font

$pdf->SetFont('freesans', '', 8, '', true);

(Original post: http://forum.virtuemart.net/index.php?topic=99347.0)

Regards