Jump to content

Core-1173 Reduce File Size Of Invoice Pdf Documents


interfasys

Recommended Posts

I just stumbled upon CORE-1173 and thought that you guys might want to consider mPDF.

 

Description

mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements.

 

Features (extract)

  • Accepts UTF-8 encoded HTML as the standard input.
  • Right-to-left languages supported.
  • CSS stylesheets with support for most CSS properties.
  • Automatic font substitution for specified languages.
  • Use any TrueType Unicode font or OpenType font with TrueType outlines.
  • Font subsetting.
  • Support for most JPEG, GIF, PNG, WMF and SVG images.
  • Text justification.
  • Multiple columns.
  • Watermarks can be used e.g. for 'DRAFT'.
  • Password protection for the PDF file.

 

Examples

http://mpdf.bpm1.com/index.php?page=Examples

 

Installation (v5)

http://mpdf1.com/manual/index.php?tid=452

 

Next version (v6)

http://www.mpdf1.com/forum/discussion/1459/mpdf-6-0-beta-release-indic-and-other-complex-scripts

 

V6 example

http://www.mpdf1.com/repos/example61_new_mPDF_v6-0_features.pdf

 

 

I'm sure other members have suggestions they could make as well.

Link to comment
Share on other sites

I just stumbled upon CORE-1173 and thought that you guys might want to consider mPDF.

 

Description

mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements.

 

Features (extract)

  • Accepts UTF-8 encoded HTML as the standard input.
  • Right-to-left languages supported.
  • CSS stylesheets with support for most CSS properties.
  • Automatic font substitution for specified languages.
  • Use any TrueType Unicode font or OpenType font with TrueType outlines.
  • Font subsetting.
  • Support for most JPEG, GIF, PNG, WMF and SVG images.
  • Text justification.
  • Multiple columns.
  • Watermarks can be used e.g. for 'DRAFT'.
  • Password protection for the PDF file.

 

Examples

http://mpdf.bpm1.com/index.php?page=Examples

 

Installation (v5)

http://mpdf1.com/manual/index.php?tid=452

 

Next version (v6)

http://www.mpdf1.com/forum/discussion/1459/mpdf-6-0-beta-release-indic-and-other-complex-scripts

 

V6 example

http://www.mpdf1.com/repos/example61_new_mPDF_v6-0_features.pdf

 

 

I'm sure other members have suggestions they could make as well.

 

That looks cool. +1

Link to comment
Share on other sites

  • 4 weeks later...

I did some research today and realised that this problem can easily be fixed by using another font. Specifically I believe the default should be a PDF/A font to ensure that the font is embedded with the pdf file and that the file meets the pdf/a ISO standard. I switched to pdf/a helvetica and my invoice file size dropped from 600+KB to 72KB which is good enough for me.

 

I forgot to mention where I got the font file. 

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

You can download the font pack from the tcpdf website and just upload the fonts you want to use to the /vendors/tcpdf/fonts directory.

Link to comment
Share on other sites

That will not work with language that have a special caractere as dejavu font is universal and support all language . i think ghis is the main reson why is includud by default in blesta .

I see, I understand your point about support for all languages. In this case my idea is a workaround for some users but the root of the problem still needs to be addressed. I was thinking about whether it would be possible to compile subsets of the dejavu font depending on the supported languages we install with Blesta. So then depending on the client's preferred language the invoice can be generated using either Latin, Greek, Cyrillic, Armenian, Georgian, etc subset instead of the entire dejavu font being embedded. Does this make sense?

Link to comment
Share on other sites

with some research i found that the TCPDF has a option to embeded only the caractere used in the pdf with the $pdf->setFontSubsetting(true);

i don't yet tested or searched in blesta side , but we will watign the blesta staff to confirm us this option is already in the pdf warapper or not .

i do't have time to fetch the TCPDF genarating pdf in blesta to how how it work , but i belive the staff can reponse to save me hours of testing :)

EDIT

i see blesta is using a old library 4.9.004 , the actual version is

Version: 6.0.091

Release date: 2014-08-13

this version maybe has the fix for this bug/problem .

blesta should update the code .

Link to comment
Share on other sites

with some research i found that the TCPDF has a option to embeded only the caractere used in the pdf with the $pdf->setFontSubsetting(true);

i don't yet tested or searched in blesta side , but we will watign the blesta staff to confirm us this option is already in the pdf warapper or not .

i do't have time to fetch the TCPDF genarating pdf in blesta to how how it work , but i belive the staff can reponse to save me hours of testing :)

Check the CORE issue, they're talking about this.

Link to comment
Share on other sites

Check the CORE issue, they're talking about this.

i found that :

TCPDF has a feature (in version 6.0.072, possibly older), that allows embedding only characters in the document that are used within the document (part of TCPDF::SetFont(); $subset parameter). However, TCPDF is a monstrosity (24K lines of code, 870 KB+ single file) that may cause more problems than it solves.

so the problem they have now maybe a re-coding of the class generator for invoices , but is not sure that the new version will resolve the probleme

Link to comment
Share on other sites

i have updated the tcpdf to 6.0.091 in a test blesta , i have just changed some vars in the default invoice class , the generator work and i can download the file and see it , the file size is now 17KB but i have the fallowing probleme ,

- the font dejavusanscondensed is not loaded at all , so the no UTF-8 caractere is shown as ????

- margin and padding for the client and invoice details need to be re-adjusted .

i will make some more test this night to see if i can resolve this .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...