Jump to content

[SOLVED] PDF with cyrillic "bug" (fonts problem)


Recommended Posts

Hi nobody78! (very weird to say that, usualy I say "Hi everybody" lol)

You should ask to "Zhivko" who worked very much on this feature.
We made the PDF "utf-8 hack" together, and I think he will enjoy to help you and will be definitly faster on this domain than me (because of not having his hand on the whole PrestaShop code but only on the encoding section).

Link to comment
Share on other sites

I have edited classes/PDF.php

       function PDF($orientation='P', $unit='mm', $format='A4')
       {
               global $cookie;

               if (!isset($cookie) OR !is_object($cookie))
                       $cookie->id_lang = intval(Configuration::get('PS_LANG_DEFAULT'));
                       $lang=strtoupper($lang);
                               self::$_pdfparams[$lang] = array('encoding' => $conf['PS_PDF_ENCODING'],
                                                               'font' => $conf['PS_PDF_FONT']);

                               FPDF::FPDF($orientation, $unit, $format);

                               $font = self::embedfont();
                               if($font) {
                               $this->AddFont($font);
                               $this->AddFont($font, 'B');
                                            }
       }



result

PDF was created, but cyrillic font disappear
...and PDF always with Helvetica font (((

1278_Pf4F1dcIKIVkvFWPGshn_t

Link to comment
Share on other sites

[sOLVED]

1) Firts of all we have clean install RC5 (if NOT, this not work for previous generated invoices)
2) Second, we should have TTF font supported necessary simbols for your language
3) Third. Go to http://fpdf.fruit-lab.de/ choose map and convert font files to need format
4) (if all OK) Download .php and .z files and rename *.php.txt to *.php
5) Do NOT change files name
6) Place this files to ./tools/fpdf/font folder
7) Replace function PDF in ./classes/PDF.php with code below

function PDF($orientation='P', $unit='mm', $format='A4')
   {
       global $cookie;

       if (!isset($cookie) OR !is_object($cookie))
           $cookie->id_lang = intval(Configuration::get('PS_LANG_DEFAULT'));
       $lang = strtoupper(Language::getIsoById($cookie->id_lang));
       $conf = Configuration::getMultiple(array('PS_PDF_ENCODING_'.$lang, 'PS_PDF_FONT_'.$lang));
       $conf['PS_PDF_ENCODING'] = (isset($conf['PS_PDF_ENCODING_'.$lang]) AND $conf['PS_PDF_ENCODING_'.$lang] == true) ? $conf['PS_PDF_ENCODING_'.$lang] : 'iso-8859-1';
       $conf['PS_PDF_FONT'] = (isset($conf['PS_PDF_FONT_'.$lang]) AND $conf['PS_PDF_FONT_'.$lang] == true) ? $conf['PS_PDF_FONT_'.$lang] : 'Arial';
       self::$_pdfparams[$lang] = array('encoding' => $conf['PS_PDF_ENCODING'],
                                       'font' => $conf['PS_PDF_FONT']);
       FPDF::FPDF($orientation, $unit, $format);
       $font = self::embedfont();
           if($font) {
                   $this->AddFont($font);
                   $this->AddFont($font, 'B');
               }        

   }



Save and close

8) Go to administration panel - Preferences >> PDF, choose Encoding and created Font
9) All done. Enjoy!

Thanks for superhero495, mazvv, Bad_Boy, me and Presta-team ))

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

installation version 1.0.0.8

created fonts uploaded .z file and .php(the one renamed from .txt) to /tools/fpdf/font/
on backoffice i choose the encoding and the newfont (6681708a4f_arial) and save changes.
When i go to an order and click on pdf icon.

I get:
FPDF error: Could not include font definition file

Ofcourse i get an incorrect pdf invoice while using any other font or encoding.

p.s
my pdf.php translation file is tested either in normal utf-8 or even in my own encoding.

Thanks in advance

Link to comment
Share on other sites

  • 4 months later...
installation version 1.0.0.8

created fonts uploaded .z file and .php(the one renamed from .txt) to /tools/fpdf/font/
on backoffice i choose the encoding and the newfont (6681708a4f_arial) and save changes.
When i go to an order and click on pdf icon.

I get:
FPDF error: Could not include font definition file

Ofcourse i get an incorrect pdf invoice while using any other font or encoding.

p.s
my pdf.php translation file is tested either in normal utf-8 or even in my own encoding.

Thanks in advance
I get the same thing
can someone give any further info?
Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...

Hi everybody,
i appreciate your work,
but this is not working for me... every time, i get this error: FPDF error: Could not include font definition file
i want to add Arial font, with cp1251 encoding, for Macedonian Cyrillic letters (or am i doing it wrong? should I add a Mac C Times font or similar?)

i uploaded arial.ttf on this web, and downloaded four files :
*.php;
*.z;
*.t1a.ps;
*.afm;


I tried to follow FPDF Tutorial7 , but i cant understand the last step Declaration of the font in the script... where do i add that code line?

$pdf->AddFont('Arial','','arial.php');

in which script??


any help please,
Alek

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

7) Replace function PDF in ./classes/PDF.php with code below

Version 1.4.6.2 does not have this function in the pdf.php file. Therefore I could not finish with the instructions. Perhaps as a result of this I also get this error menioned already in this thread when I select the font that I have uploaded. :( and still no cyrillic for me.

Success with this anyone?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...