#1 2016-01-12 06:08:56

wangwen
Member
Registered: 2016-01-12
Posts: 6

Why embed font in the pdf file, the pdf file become vary large?

Why embed font in the pdf file, the pdf file become vary large? who can give me some advice, thank you!

Offline

#2 2016-01-12 17:32:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Why embed font in the pdf file, the pdf file become vary large?

Did you embed the sub-set, or the whole font?

Usually, the sub-set if small enough.

Offline

#3 2016-01-14 06:58:00

wangwen
Member
Registered: 2016-01-12
Posts: 6

Re: Why embed font in the pdf file, the pdf file become vary large?

How to embed the sub-set ? I only find property EmbeddedTTF: boolean read fEmbeddedTTF write fEmbeddedTTF, I make EmbeddedTTF := True;
Can you told me how to embed the sub-set?  I use the version sorce 1.18, I got it from http://synopse.info/files/pdf/synpdf.zip in 2015-03-16.
I use Delphi 7.

Thank you!!!

ab wrote:

Did you embed the sub-set, or the whole font?

Usually, the sub-set if small enough.

Offline

#4 2016-01-14 09:10:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Why embed font in the pdf file, the pdf file become vary large?

The sub-set is embedded using the Windows API.

Perhaps the Windows API is not able to sub-set this kind of font.

Offline

#5 2016-01-15 01:46:30

wangwen
Member
Registered: 2016-01-12
Posts: 6

Re: Why embed font in the pdf file, the pdf file become vary large?

Do you mean that the pdf will be embed the sub-set, if I make EmbeddedTTF := True and windows api support ?
Can I call the method to embed sub-set?

Thank you !

ab wrote:

The sub-set is embedded using the Windows API.

Perhaps the Windows API is not able to sub-set this kind of font.

Offline

#6 2016-04-12 12:50:27

SergioHC
Member
Registered: 2016-04-12
Posts: 1

Re: Why embed font in the pdf file, the pdf file become vary large?

Try this way:

  PDF_Doc.EmbeddedTTF:= True;
  PDF_Doc.EmbeddedTTFIgnore.Text:= MSWINDOWS_DEFAULT_FONTS;
  PDF_Doc.EmbeddedWholeTTF:= false;

Second line avoid "Arial" or "Courier New" to be embeded in the file (but Linux wont see Symbols, for instance!), and third line avoid arab or chinesse characters -if defined in your font- to be embeded in the PDF when the doc is not really using them (a whole TFF font can be 12MB easily, while the used "subset" can be 60KB).

After many tries with this combination, only some special chars in symbol font are failing to show when PDF is open in a linux (greater or equal than, for instance), not sure if the win api for creating subsets fails, so I made some changes to V1.18 so I can give it a list of fonts (with only "Symbol") that, if embeded, must be full embeded.

It saved me for this last problem at a cost of 15KB, but I had to change the source code a little:

1) I cloned all the code related to "SubSetTTFIgnore" and made a clone property named "EmbeddedTTFIgnore".

2) I use this property (bold line on the code) on the part where using subset is decided (procedure TPdfFontTrueType.PrepareForSaving):

        ...
        if ttfSize<>GDI_ERROR then begin
          SetLength(ttf,ttfSize);
          if GetFontData(fDoc.FDC,tableTag,0,pointer(ttf),ttfSize)<>GDI_ERROR then begin
            fFontFile2 := TPdfStream.Create(fDoc);
            if not fDoc.fEmbeddedWholeTTF
              and (fDoc.fSubsetTTFIgnore.IndexOf(fDoc.FTrueTypeFonts[fTrueTypeFontsIndex-1])<0)
              then begin
              if FontSub=INVALID_HANDLE_VALUE then begin
                FontSub := SafeLoadLibrary('FontSub.dll');
                if FontSub<>0 then
                  CreateFontPackage := GetProcAddress(FontSub,'CreateFontPackage');
                  ....

And in my own code, I just do it like this:

uses
  SynPdf, SynCommons;

const
  NO_FONTS: RawUTF8 = 'Arial'#13#10'Courier New'#13#10'Times New Roman';
  SYM_FONT: RawUTF8 = 'Symbol';

  PDF_Doc.EmbeddedTTF:= True;
  PDF_Doc.EmbeddedTTFIgnore.Text:= NO_FONTS;
  PDF_Doc.EmbeddedWholeTTF:= false;
  PDF_Doc.SubsetTTFIgnore.Text:= SYM_FONT;

Last edited by SergioHC (2016-04-12 12:52:56)

Offline

Board footer

Powered by FluxBB