Jump to content

prestashop 1.5.0.13 RC PDF encoding


Recommended Posts

  • 1 month later...

Hi, I had the same problem.

It seems you can't set encoding or font in 1.5.0.13 (according to my findings in BO). But it also seems to be temporary, according to this bug tracker comment: http://forge.prestashop.com/browse/PSCFV-1887?focusedCommentId=52279&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-52279

 

In that comment you'll find a working solution for changing font.

I tested with freeserif, for czech characters (well, just "č" in fact, i still don't have the invoice transalted).

 

I'd just recommend instead of editing /prestashop/classes/pdf/PDFGenerator.php, edit /prestashop/override/classes/pdf/PDFGenerator.php - It works just the same, but you don't get lost in editing core files.

By default, the file looks like this:

 

<?php
class PDFGenerator extends PDFGeneratorCore
{
}

 

You want to change it to this (with the font that works for you):

 

<?php
class PDFGenerator extends PDFGeneratorCore
{
public function setFontForLang($iso_lang)
{
 $this->setFont('freeserif');
}
}

 

 

The system checks for language used, before setting which font to use for generating the pdf. It's just there's nowhere to define which fonts go with which languages, but that shouldn't take long. (I'd say it's important and easy enough to be fixed in final version. When the pdf generator is already (finally, for us non-basic-latin) changed :).)

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi, I had the same problem.

It seems you can't set encoding or font in 1.5.0.13 (according to my findings in BO). But it also seems to be temporary, according to this bug tracker comment: http://forge.prestas...l#comment-52279

 

In that comment you'll find a working solution for changing font.

I tested with freeserif, for czech characters (well, just "č" in fact, i still don't have the invoice transalted).

 

I'd just recommend instead of editing /prestashop/classes/pdf/PDFGenerator.php, edit /prestashop/override/classes/pdf/PDFGenerator.php - It works just the same, but you don't get lost in editing core files.

By default, the file looks like this:

 

<?php
class PDFGenerator extends PDFGeneratorCore
{
}

 

You want to change it to this (with the font that works for you):

 

<?php
class PDFGenerator extends PDFGeneratorCore
{
public function setFontForLang($iso_lang)
{
 $this->setFont('freeserif');
}
}

 

 

The system checks for language used, before setting which font to use for generating the pdf. It's just there's nowhere to define which fonts go with which languages, but that shouldn't take long. (I'd say it's important and easy enough to be fixed in final version. When the pdf generator is already (finally, for us non-basic-latin) changed :).)

 

Thank you. Russian works pdf

Link to comment
Share on other sites

To Core developers: Is it possible to add a dropdown list of fonts supported by TCPDF in BO? Let's merchants decide which font is compatible and looks much correct.

http://www.tcpdf.org/fonts.php

 

At least, the PDF Core (standard) fonts are:

  • courier : Courier
  • courierB : Courier Bold
  • courierBI : Courier Bold Italic
  • courierI : Courier Italic
  • helvetica : Helvetica
  • helveticaB : Helvetica Bold
  • helveticaBI : Helvetica Bold Italic
  • helveticaI : Helvetica Italic
  • symbol : Symbol
  • times : Times New Roman
  • timesB : Times New Roman Bold
  • timesBI : Times New Roman Bold Italic
  • timesI : Times New Roman Italic
  • zapfdingbats : Zapf Dingbats

I see it's possible to upload a TTF to server and convert it for TCPDF.

 

Another feature - Google Fonts ;)

Link to comment
Share on other sites

I see a lot of changes in the svn regarding to PDF

A    tools/tcpdf/encodings_maps.php
A    tools/tcpdf/datamatrix.php
A    tools/tcpdf/tcpdf.php
A    tools/tcpdf/tcpdf.crt
A    tools/tcpdf/fonts
A    tools/tcpdf/fonts/cid0jp.php
A    tools/tcpdf/fonts/freeserif.php
A    tools/tcpdf/fonts/freeserif.z
A    tools/tcpdf/fonts/helveticai.php
A    tools/tcpdf/fonts/helveticabi.php
A    tools/tcpdf/fonts/dejavusans.ctg.z
A    tools/tcpdf/fonts/dejavusans.php
A    tools/tcpdf/fonts/helvetica.php
A    tools/tcpdf/fonts/dejavusans.z
A    tools/tcpdf/fonts/helveticab.php
A    tools/tcpdf/fonts/freeserif.ctg.z
A    tools/tcpdf/sRGB.icc
A    tools/tcpdf/pdf417.php
A    tools/tcpdf/spotcolors.php
A    tools/tcpdf/tcpdf.fdf
A    tools/tcpdf/LICENSE.TXT
A    tools/tcpdf/tcpdf.p12
A    tools/tcpdf/tcpdf_parser.php
A    tools/tcpdf/cache
A    tools/tcpdf/cache/table_data_demo.txt
A    tools/tcpdf/cache/utf8test.txt
A    tools/tcpdf/cache/chapter_demo_1.txt
A    tools/tcpdf/cache/chapter_demo_2.txt
A    tools/tcpdf/qrcode.php
A    tools/tcpdf/unicode_data.php
A    tools/tcpdf/config
A    tools/tcpdf/config/lang
A    tools/tcpdf/config/lang/urd.php
A    tools/tcpdf/config/lang/mlt.php
A    tools/tcpdf/config/lang/heb.php
A    tools/tcpdf/config/lang/hrv.php
A    tools/tcpdf/config/lang/zho.php
A    tools/tcpdf/config/lang/bel.php
A    tools/tcpdf/config/lang/dan.php
A    tools/tcpdf/config/lang/slv.php
A    tools/tcpdf/config/lang/srp.php
A    tools/tcpdf/config/lang/cat.php
A    tools/tcpdf/config/lang/far.php
A    tools/tcpdf/config/lang/ces.php
A    tools/tcpdf/config/lang/mkd.php
A    tools/tcpdf/config/lang/hat.php
A    tools/tcpdf/config/lang/ger.php
A    tools/tcpdf/config/lang/nob.php
A    tools/tcpdf/config/lang/kat.php
A    tools/tcpdf/config/lang/msa.php
A    tools/tcpdf/config/lang/bul.php
A    tools/tcpdf/config/lang/yid.php
A    tools/tcpdf/config/lang/hye.php
A    tools/tcpdf/config/lang/cym.php
A    tools/tcpdf/config/lang/swa.php
A    tools/tcpdf/config/lang/pol.php
A    tools/tcpdf/config/lang/hun.php
A    tools/tcpdf/config/lang/est.php
A    tools/tcpdf/config/lang/kor.php
A    tools/tcpdf/config/lang/sqi.php
A    tools/tcpdf/config/lang/eus.php
A    tools/tcpdf/config/lang/swe.php
A    tools/tcpdf/config/lang/ron.php
A    tools/tcpdf/config/lang/por.php
A    tools/tcpdf/config/lang/ukr.php
A    tools/tcpdf/config/lang/ara.php
A    tools/tcpdf/config/lang/chi.php
A    tools/tcpdf/config/lang/bra.php
A    tools/tcpdf/config/lang/gle.php
A    tools/tcpdf/config/lang/afr.php
A    tools/tcpdf/config/lang/fra.php
A    tools/tcpdf/config/lang/glg.php
A    tools/tcpdf/config/lang/eng.php
A    tools/tcpdf/config/lang/rus.php
A    tools/tcpdf/config/lang/ind.php
A    tools/tcpdf/config/lang/ita.php
A    tools/tcpdf/config/lang/nld.php
A    tools/tcpdf/config/lang/aze.php
A    tools/tcpdf/config/lang/spa.php
A    tools/tcpdf/config/lang/jpn.php
A    tools/tcpdf/config/tcpdf_config.php
A    tools/tcpdf/config/tcpdf_config_alt.php
A    tools/tcpdf/barcodes.php
A    tools/tcpdf/htmlcolors.php
A    tools/tcpdf/tcpdf_filters.php

Hope it solve the llocal fonts/encodings problem in PDF, will test it!

 

Default font still doesn't changed:

class PDFGeneratorCore extends TCPDF

{

const DEFAULT_FONT = 'helvetica';

Edited by Nick Fedchik (see edit history)
Link to comment
Share on other sites

PrestaShop 1.5.0.15 classes\pdf\PdfGenerator.php line 37 cnange
 const DEFAULT_FONT = 'helvetica'; 

to

 const DEFAULT_FONT = 'freeserif'; 

UPDATE: Works fine both on my workstation with Win7 and on CentOS 6.3 server

 

OMG! You're genius! WORKS! :)

 

THANK YOU!

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 1 month later...
  • 5 weeks later...
  • 1 month later...

PrestaShop 1.5.0.15

classes\pdf\PdfGenerator.php

line 37

cnange

const DEFAULT_FONT = 'helvetica';

to

const DEFAULT_FONT = 'freeserif';

 

UPDATE: Works fine both on my workstation with Win7 and on CentOS 6.3 server

 

Thanks!

 

In case of the hungarian special characters:

const DEFAULT_FONT = 'dejavusans';

Edited by wram (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...
  • 7 months later...
  • 2 months later...
  • 1 year later...
×
×
  • Create New...