Lithuanian letters have question marks when generated to pdf in invoice/email

Started by juslintek, September 21, 2014, 17:10:36 PM

Previous topic - Next topic

juslintek

Here it is shown in the video, its new Joomla installation, with some premade data migrated for testing purposes. Sorry for my silent voice and crappy pronounciation. But I think its understandable. :-)

http://youtu.be/h55JyLXgHFU

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jjk

Here is a link to a forum post with the same issue:
http://forum.virtuemart.net/index.php?topic=120243.msg409539#msg409539
It's not marked as 'solved', but maybe installing a dejavu font into the tcpdf folder helps. I didn't test that myself, so do I'm not shure if it will solve the problem.
Maybe this link has some valuable information: http://stackoverflow.com/questions/5333702/tcpdf-utf-8-lithuanian-symbols-not-showing-up
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

juslintek

Quote from: Milbo on September 22, 2014, 11:32:04 AM
http://forum.virtuemart.net/index.php?topic=99347.15 maybe this post helps you.

Well on 2.9.9b    public function samplePDF() { function beings on line 178 on frontend componenets invoice.php Still I need to install DejaVuSans font. Because it cannot identify it.

So I've imported DejaVuSans font via php commandline, when changing tcpdf_autoconfig.php JPATH_ROOT in K_IMAGE_PATH definition to $_SERVER['DOCUMENT_ROOT'].

And then used it in. samplePDF function, and it fixed it. But probably after 2.9.9b update to higher i'll have to remake it again.

Even though I change this function the way you see it now:


components/com_virtuemart/controllers/invoice.php

line 178
public function samplePDF() {
      if(!class_exists('VmVendorPDF')){
         vmError('vmPdf: For the pdf, you must install the tcpdf library at '.JPATH_VM_LIBRARIES.DS.'tcpdf');
         return 0;
      }

      $pdf = new VmVendorPDF();

      $pdf->setHeaderFont(Array('dejavusans', '', 8 )); //was nothing before
      $pdf->setFooterFont(Array('dejavusans', '', 10 )); //was nothing before

      $pdf->AddPage();
      $pdf->PrintContents(vmText::_('COM_VIRTUEMART_PDF_SAMPLEPAGE'));
      $pdf->Output("vminvoice_sample.pdf", 'I');
      JFactory::getApplication()->close();
   }
libraries/joomla/document/pdf.php

line 32 33

/*   var $_header_font = 'courier';
   var $_footer_font = 'courier';*/

   var $_header_font = 'dejavusans';
   var $_footer_font = 'dejavusans';

line 222

      //$pdf->SetFont('helvetica', '', 8, '', 'false');
      $pdf->SetFont('dejavusans', '', 8, '', 'false');




Still problem persists as in attachment below
Sample Invoice with lithuanian letters

P.S. I've added new font via php commandline like this:

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSans.ttf added as dejavusans
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-Bold.ttf"
medziokle/domains/pressline.lt/public_html/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-ExtraLight.ttf"
php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSansCondensed-BoldOblique.ttf"
php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSansCondensed.ttf"
php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-BoldOblique.ttf"
php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-Oblique.ttf"
php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSansCondensed-Bold.ttf"
php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-Oblique.ttf"
>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSans-Bold.ttf added as dejavusansb
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-ExtraLight.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSans-ExtraLight.ttf added as dejavusansextralight
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSansCondensed-BoldOblique.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSansCondensed-BoldOblique.ttf added as dejavusanscondensedbi
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSansCondensed.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSansCondensed.ttf added as dejavusanscondensed
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-BoldOblique.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSans-BoldOblique.ttf added as dejavusansbi
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-Oblique.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSans-Oblique.ttf added as dejavusansi
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSansCondensed-Bold.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSansCondensed-Bold.ttf added as dejavusanscondensedb
>>> Process successfully completed!

/libraries/tcpdf/tools$ php tcpdf_addfont.php -o "/libraries/tcpdf/fonts" -i "/dejavusans/DejaVuSans-Oblique.ttf"

>>> Converting fonts for TCPDF:
*** Output dir set to /libraries/tcpdf/fonts/
+++ OK   : /dejavusans/DejaVuSans-Oblique.ttf added as dejavusansi


juslintek

Quote from: jjk on September 22, 2014, 12:21:46 PM
Here is a link to a forum post with the same issue:
http://forum.virtuemart.net/index.php?topic=120243.msg409539#msg409539
It's not marked as 'solved', but maybe installing a dejavu font into the tcpdf folder helps. I didn't test that myself, so do I'm not shure if it will solve the problem.
Maybe this link has some valuable information: http://stackoverflow.com/questions/5333702/tcpdf-utf-8-lithuanian-symbols-not-showing-up

I've changed samplePDF function like this:
   public function samplePDF() {
      if(!class_exists('VmVendorPDF')){
         vmError('vmPdf: For the pdf, you must install the tcpdf library at '.JPATH_VM_LIBRARIES.DS.'tcpdf');
         return 0;
      }

      $pdf = new VmVendorPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
      //$pdf = new VmVendorPDF();
      $pdf->setHeaderFont(Array('dejavusans', '', 8 ));
      $pdf->setFooterFont(Array('dejavusans', '', 10 ));
      $pdf->AddPage();
      $pdf->PrintContents(vmText::_('COM_VIRTUEMART_PDF_SAMPLEPAGE'));
      $pdf->Output("vminvoice_sample.pdf", 'I');
      JFactory::getApplication()->close();
   }


Doesn't help...

jjk

Here is another link: http://forum.virtuemart.net/index.php?topic=99347.0
Maybe you can find additional help if you use Google and search for something like: virtuemart lithunian font
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

juslintek

Quote from: jjk on September 23, 2014, 10:27:19 AM
Here is another link: http://forum.virtuemart.net/index.php?topic=99347.0
Maybe you can find additional help if you use Google and search for something like: virtuemart lithunian font

Yep, this one helped:

FreeSans font added as well as function in controller/invoice.php changed:

   public function samplePDF() {
      if(!class_exists('VmVendorPDF')){
         vmError('vmPdf: For the pdf, you must install the tcpdf library at '.JPATH_VM_LIBRARIES.DS.'tcpdf');
         return 0;
      }

      $pdf = new VmVendorPDF;
      //$pdf = new VmVendorPDF();
      $pdf->setHeaderFont(Array('freesans', '', 8 ));
      $pdf->SetFont('freesans', '', 10);
      $pdf->setFooterFont(Array('freesans', '', 10 ));
      $pdf->AddPage();
      $pdf->PrintContents(vmText::_('COM_VIRTUEMART_PDF_SAMPLEPAGE'));
      $pdf->Output("vminvoice_sample.pdf", 'I');
      JFactory::getApplication()->close();
   }


I will make a proper description later.

spi7fire

Thank you for this great solution, helped me a lot with vm3 (It's a bit annoying that vm3 still doesnt support multi-language invoices)

Anyway, i'm having a different issue now - the page is being displayed in LTR, and i need it in RTL (arabic/hebrew).   How can i turn it over? 

Thanks