1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Custom PDF template doesn't print to PDF with polish characters

Discussion in 'Professional Support' started by blue-mouse, Jan 26, 2016.

Thread Status:
Not open for further replies.
  1. blue-mouse

    blue-mouse Member

    Level: Community
    Hi,
    I have my own list template:
    /com_fabrik/views/list/tmpl/default-2015-12-14-table-zlicz-pakiety-pdf1
    that i use as:
    - Front-end-template
    and
    -PDF template ( PDF Orientation: Portrait, PDF Paper size: a2)

    This is very customized template - list view include only:
    -box for searching (field: ccjom_cc_kk_karta_rejestr___zamow_symbol) --
    Szukaj:
    Nr zam.

    - calculations ( some calculations are fabrik calculations for columns, some calculations are my own advanced calculations with code in file:

    /com_fabrik/views/list/tmpl/default-2015-12-14-table-zlicz-pakiety-pdf1/default.php

    A piece of list view is in screenshoot: Zaznaczenie_127.png

    My own code in default.php is for example this piece of code:
    PHP:

    <?php  $n=0;

                            foreach ($this->calculations as $cal) {

    if($n >=7 and $n<8)  {
                                     echo '<tr class="fabrik_calculations">';
                                            echo "<td>";


    echo " <div class='podkr1' style='margin-top: -7px; margin-bottom: -13px; text-align:right;'>  </div><br/>";
    echo " <div class='tyt1'> Pakiety wej?? analogowych: - - - - - Add2 </div><br/>";
    $db =& JFactory::getDBO();


    for ($i=1; $i<=5; $i++){

    if ($order1==0){
    $query = "SELECT  `is_pak_xxxx`, `field_pakiety_analogowe` FROM  `ccjom_cc_kk_karta_rejestr` WHERE ( `rodzaj_karty_np_wzorzec`= '2' and `field_pakiety_analogowe`="$
    }
    else {
    $query = "SELECT  `is_pak_xxxx`, `field_pakiety_analogowe`  FROM `ccjom_cc_kk_karta_rejestr` WHERE ( `zamow_symbol`=".$order1."  and `field_pakiety_analogowe`=".$i$
    }
     

    I have a problem with line like this:
    echo " <div class='tyt1'> Pakiety wej?? analogowych: - - - - - Add2 </div><br/>";

    "wej??" - include polish characters : ?, ? that are well displayed on list_view but wrong on PDF-printout.


    I try also add at the beginning of file default.php - line with code:
    PHP:
     header('Content-type: text/plain; charset=utf-8');
     
    but this doesn't change nothing

    On PDF-printout i get line:
    echo " <div class='tyt1'> Pakiety wej?? analogowych: - - - - - Add2 </div><br/>";
    without polish characters, i get instead them: "??".
    Sample of PDF-output i have on screenshoot: Zaznaczenie_128.png.

    I can copy directory:
    /com_fabrik/views/list/tmpl/default-2015-12-14-table-zlicz-pakiety-pdf1
    to directory:
    /com_fabrik/views/list/tmpl/default-2015-12-14-table-zlicz-pakiety-pdf1-printout
    And can do independent template for PDF-output.

    But what and how to change code to get in PDF polish characters?
    Now need to solve problem with lines like:
    echo " <div class='tyt1'> Pakiety wej?? analogowych: - - - - - Add2 </div><br/>";
    that are only in default.php file.

    Link to list

    Neccessary is login to site.
     

    Attached Files:

    Last edited: Jan 26, 2016
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    You may need to run the output through mb_convert_encoding. Around line 145 in ./libraries/joomla/document/pdf/pdf.php, just before we do the load_html(), try ...

    Code (Text):

    $data = mb_convert_encoding($data,'HTML-ENTITIES','UTF-8');
     
    You might also try using a different font, as per this Stack Overflow discussion:

    http://stackoverflow.com/questions/16384517/dompdf-character-encoding-utf-8

    You can see in that code where we've tested using different fonts before.

    -- hugh
     
    blue-mouse likes this.
  3. troester

    troester Well-Known Member Staff Member

    Level: Community
    blue-mouse likes this.
  4. blue-mouse

    blue-mouse Member

    Level: Community
    Hi,

    This works (i get polish characters on pdf) when i use:
    - in ./libraries/joomla/document/pdf/pdf.php: ---before we do the load_html()---
    $data = mb_convert_encoding($data,'HTML-ENTITIES','UTF-8');

    - in custom_css.php:
    * {font-family:arial!important}

    I need this 2 lines with code both to have polish characters in PDF.
    -------------------------------------------------------------------------------

    I try also second option in link from troester
    - in custom_css.php:
    * {font-family:'dejavu sans'!important}
    but this doesn't work.
    --------------------------------------------------------------------------------

    This what i get now is enought for me for polish characters in PDF for that list.

    Very thanks! :)
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Yeah, I think there's an issue where certain characters get converted to HTML entities rather than UTF-8 encoded, when rendering a view.

    -- hugh
     
  6. blue-mouse

    blue-mouse Member

    Level: Community
    Thanks, again.
    SOLVED
     
Thread Status:
Not open for further replies.

Share This Page