Author Topic: [SOLVED] UTF-8 support in PDF Invoice  (Read 26991 times)

Artanis

  • Beginner
  • *
  • Posts: 32
  • Zusurs...
    • Animus Design Studio (coming soon)
[SOLVED] UTF-8 support in PDF Invoice
« 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. I'll check this out and notify here.

Thanks in advance, guys. I appreciate any help.
Best regards, Arthur.
Animus Project - Design Studio
Running Joomla 2.5.6, Virtuemart 2.0.6a, PHP 5.3.10

Artanis

  • Beginner
  • *
  • Posts: 32
  • Zusurs...
    • Animus Design Studio (coming soon)
Re: UTF-8 support in PDF Invoice?
« Reply #1 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!

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.
Animus Project - Design Studio
Running Joomla 2.5.6, Virtuemart 2.0.6a, PHP 5.3.10

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27767
  • Always on vacation
    • Jenkin Hill Internet
Re: UTF-8 support in PDF Invoice
« Reply #2 on: March 18, 2012, 23:18:34 pm »
Thank you for this.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.8.4.10335 on Joomla 3.9.19 PHP 7.3.18

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: UTF-8 support in PDF Invoice
« Reply #3 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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!