Menu

Large PDF size while using UTF8 font

Help
2015-05-22
2015-07-10
  • SilverSilencer

    SilverSilencer - 2015-05-22

    I am using tcpdf_5.0.002 and the only utf8 supported font is freeserif and when I use it my PDF file is around 1MB in size even when empty or a few words are displayed. If I don't use freeserif font size is 50kb, but I must use UTF8 characters. Is there any way to reduce that size of PDF (maybe use only Subset)?

     
    • Simon

      Simon - 2015-05-22
       
  • SilverSilencer

    SilverSilencer - 2015-05-22

    I have read and tried lots of things but the result is never correct (if utf8 chars show then size is large, if size is small, utf8 chars are not shown). I don't know what am I doing wrong. This is what I have now, should I change something?

        require_once('html2pdf.class.php');
        $html2pdf = new HTML2PDF('P','A4','en', true, 'UTF-8');
        $html2pdf->pdf->SetTitle('PDF');
        $html2pdf->pdf->SetDisplayMode('real');
        $html2pdf->setDefaultFont('freeserif');
        $html2pdf->writeHTML($content);
        $html2pdf->Output('new.pdf', 'D');
    

    And the problem is only with 1 character. Is there any way to manually add some code to include that letter?

     

    Last edit: SilverSilencer 2015-05-22
    • Simon

      Simon - 2015-05-22

      Have you tried setting the font like this:

      $pdf->SetFont('freeserif', 'BI', 20, '', 'true');
      
       
      • SilverSilencer

        SilverSilencer - 2015-05-22

        I tried like this but some utf8 characher still doesn't work.

        I have now found this website fonts.snm-portal.com where I can insert font and use that and it works great. So for now I will use this. :)

         
  • NameName Name

    NameName Name - 2015-07-10

    We are attempting to migrate to FrontAccounting and after realizing, UTF-8 was not the default (one of those wtf!? moments), we changed it as instructed.

    After UTF-8, Invoice pdf file size ballooned from 12.6 KiB to 526.9KiB. (same invoice, btw) and invoice looks like crap with all the � in it.

    As you can probably understand, this is not acceptable size for a simple Invoice because we have to email every Invoice to our clients.

    Any ideas, how to fix this?

     

Log in to post a comment.