-1

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?

steven
  • 4,868
  • 2
  • 28
  • 58
  • Well certainly the generated document is smaller if it does _not_ contain an embedded font. However keep in mind that although most likely it can be displayed (the pdf interpreter will chose some suitable locally installed font), its appearance may vary from system to system. Especially when relying on proprietary fonts like `Arial` that are not available everywhere. – arkascha May 27 '15 at 09:43

1 Answers1

1

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.

David van Driessche
  • 6,602
  • 2
  • 28
  • 41
  • I can confirm that. I found this documentation: http://www.fpdf.org/en/doc/setfont.htm The documentation says: Helvetica or Arial (synonymous; sans serif). I don't really know what it means but it is not important for me if it will be arial, helvetica or another sans serif font. I noticed that the Standard fonts use the Windows encoding cp1252 (Western Europe) so i solved the euro sign problem by using `chr(0x80)`. What is the worst case by doing it like this? I belive that the users system will replace the font with a random sans serif font in worst case, isn't it? – steven May 27 '15 at 11:47
  • Real typographers aren't going to be happy with the synonymous statement :-) but they are very close. The worst case scenario is that you have the viewer "mock up" the font and that as a result the font would look different. If the look of the document is not your primary concern this may well be acceptable (make sure you don't have to comply with PDF standards, all PDF standards require fonts to be embedded). – David van Driessche May 27 '15 at 13:12