Author Topic: Make PDF plugin work with special characters including header and footer  (Read 9285 times)

juanmadg

  • Beginner
  • *
  • Posts: 3
Hi,

I tried to patch the PDF output with a solution posted kozaki on January. Basically he proposed modifying the /administrator/components/com_virtuemart/html/shop.pdf_output.php file by changing line 127 (in my version was line 130, close enough anyway), from:

$pdf->WriteHTML($html)

to:

$pdf->WriteHTML(utf8_decode($html))

so the pdf can work with utf-8 characters as in joomla 1.5.x

That worked well for me (although there were complaints about that hack not working with russian, armenian, etc) - someone proposed this change instead for that:

$html = mb_convert_encoding( $html, "ISO-8859-2", "UTF-8" );
$pdf->WriteHTML($html);

Anyway, I have kept first solution (utf8_decode) as it worked for me. Nontheless, I found out that I kept having problems with headers and footers in the PDF.

The header was easy, just above the pdf->WriteHTML($html) line you can find two other lines, as this:

      $pdf->PutTitle($mosConfig_sitename);
      $pdf->PutAuthor($vendor_name);
      $pdf->WriteHTML($html);

change all three in this way:

      $pdf->PutTitle(utf8_decode($mosConfig_sitename));
      $pdf->PutAuthor(utf8_decode($vendor_name));
      $pdf->WriteHTML(utf8_decode($html));

OK. PDF contents and Header ready.

For the footer it was a little more tricky, we have to change file at /administrator/components/com_virtuemart/classes/pdf/html2fpdf_site.php; in line 159 (in my version) you can find:

      $texto = "Copyright ".chr(169).date('Y')."  -  $vendor_name  -  ";

change it for:

      $texto = "Copyright ".chr(169).date('Y')."  -  ".utf8_decode($vendor_name)."  -  ";

And footer ready.

I suppose that for russian, armenian, etc... you can include the second version proposed; hacking would be in the same places but including this different code for the conversion.

Hope you will enjoy it.

Best regards,


hendrix

  • Beginner
  • *
  • Posts: 39
Re: Make PDF plugin work with special characters including header and footer
« Reply #1 on: September 26, 2009, 19:48:41 pm »
Cool. Thank you!
Joomla! 1.5.14 and VirtueMart 1.1.4 stable

plunk

  • Jr. Member
  • **
  • Posts: 53
Re: Make PDF plugin work with special characters including header and footer
« Reply #2 on: November 09, 2009, 13:08:02 pm »
tried this, still getting
���type=image,width=42.32,height=42.32��ï¿
119.96 0 0 119.96 28.35 468.66 cm /I2 Do Q

instead of an image

I have a dutch website Joomla 1.5.14, vm 1.1.3 stable:
http://www.screentech.nl/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=60&category_id=1&option=com_virtuemart&Itemid=64

xitrumice

  • Beginner
  • *
  • Posts: 2
It not working with Vietnamese ,can u help me plz