FPDF behaviour when not adding font

1.8k Views Asked by At

I noticed that PDF-Files generated with PHP using FPDF/FPDI etc grow up extremely when adding/embedding fonts to it. So I tried to avoiding to do if i use well known font-families like arial.

Assuming I only use Arial/Arial-bold and I comment out the following parts like this in my constructor:

// $this->AddFont('Arial', '', 'arial.php');
// $this->AddFont('Arial', 'B', 'arialbd.php');

what is the expected behaviour of pdfs opened on various computers?

The reason for doing this is the following:

  1. The size of my PDF is 10Kb instead of 1Mb
  2. I assume that arial is present on nearly any machine and if not the machine should replace the arial font with a similar font. The used font is not so important for my document.

Is this an intelligent approach or is it risky to use a not embedded font?

I addition please tell me what charset is used in that case. My previously embedded fonts had been of ISO-8859-15 to be able to use the euro sign. If i comment out the font embedding everything is displayed in arial on my windows machine except the euro sign. I suspect that windows uses a windows charset instead and the euro sign is on a different char.

Please give me a hint what is the best practice on create PDF-Files with FPDF without embedding fonts when using common font-families. And what charset is used by the interpreter in that case?

1

There are 1 best solutions below

2
On

In general generating PDF files without fonts embedded is a really bad idea - any viewer has their own strategy to show your PDF in that case and you have no control over the PDF files at all.

That being said, if you do want to generate PDF files without fonts (please don't :-)), PDF has a notion of standard fonts. Those are fonts that any viewer is supposed to have (you're still not sure the fonts are going to be rendered identical and you can still have encoding issues, but you have a better fighting chance).

Those fonts are: helvetica (regular, bold, italic, bold-italic), times (regular, bold, italic, bold-italic), courier (regular, bold, italic, bold-italic), symbol and zapfdingbats. That's 14 fonts in total.

And yes, Arial is relatively common but Helvetica (which is very similar) would still be a better idea in this case.