Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Font embedded multiple times
  FAQ FAQ  Forum Search   Register Register  Login Login

Font embedded multiple times

 Post Reply Post Reply
Author
Message
StanMarshall View Drop Down
Beginner
Beginner


Joined: 11 Jan 06
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote StanMarshall Quote  Post ReplyReply Direct Link To This Post Topic: Font embedded multiple times
    Posted: 18 Jan 06 at 5:04PM

Hi all...

It was great to stumble across this forum. Thanks to all who started it. I share your dismay at the apparent demise of ISED.

I have a question: Does anyone know how to get QuickPDF to only embed a font if that font has not already been embedded in the document? And, if it has already been embedded in the document, to use that font for a specific call to DrawText?

At first, I was hoping AddTrueTypeFont would just be smart enough to realize the font I am asking it to add to the document was already there and, so, to not add it again. However, that does not seem to be the case.

So I tried this:

function CheckPDFDocumentForFont(thePDF : TiSEDQuickPDF; FontName : String) : LongInt;
var
  FontCtr : Integer;
  FontCount : Integer;
  FontID : LongInt;
begin
  Result := -999;

  FontCount := thePDF.FindFonts;

  for FontCtr := 1 to FontCount do
  begin
    FontID := thePDF.FontID(FontCtr);
    thePDF.SelectFont(FontID);
    if UpperCase(thePDF.FontName) = UpperCase(FontName) then
    begin
      Result := FontID;
      exit;
    end;
  end;

  Result := -1; {font not found}
end;


function PrintTextControlOnPDFPage(...)
begin
  FontID := CheckPDFDocumentForFont(thePDF,FontName);

  if FontID < 0 then FontID := thePDF.AddTrueTypeFont(FontName,1);

  thePDF.SelectFont(FontID);

...

end;

(The PDF is already properly opened etc. before either of these routines is called.)

However, it still seems to re-embed the font for each text control that uses it. (My printing routines iterate through each visible control on a form and print each control independently...it's sort of a homegrown wysiwyg report designer.)

The font does not show up multiple times in Acrobat's "Document Properties|Fonts" list, but the space used by fonts increases (substantially) with each text control I add to the form I am printing...even if the text is only a three letter word.

Can anybody see any problems with the code I have pasted above (like why it would not find the font, or, if it does find the font, why it would re-embedd it anyway)? Or, does anyone have any ideas on how to get QuickPDF to stop embedding the same font multiple times (assuming that is really what is happening)?

I can think of a few possibilities like figuring out all of the necessary fonts and embedding them ahead of time or maintaining my own list of fonts that have been used. However, I would rather not use either of those approaches for reasons beyond the scope of this post (the second wouldn't be too bad if it works).

I would really like to be able to just ask QuickPDF "is the font used by this text control already embedded in the document? if so, just use it...if not, embed it" I can't figure out why the code I have pasted above does not seem to be doing that.

Any help would be greatly appreciated.

Thanks.

Stan



Edited by StanMarshall
Back to Top
StanMarshall View Drop Down
Beginner
Beginner


Joined: 11 Jan 06
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote StanMarshall Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jan 06 at 6:13PM

I have done some more playing around and have determined that this only happens with bold or italic fonts.

For example, "Arial [Bold]".

I think it has to do with the naming convention. Seems like QuickPDF recognizes the naming convention "fontname [Bold]" for adding fonts, but not for finding them.

A little more poking around should allow me to discover the naming convention it will use to find the fonts...then, hopefully, I'll just need to do some systematic name translation and it will work...hopefully

If I figure it out, I will post the solution so anyone else who might run into this can find the answer.

In the meantime, if anyone has any thoughts, please post them.

Thanks.

Stan

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 19 Jan 06 at 1:46AM
Hi Stan!

I've made own code searching through the whole pdf-file collecting all embedded fonts and offer the result as a user information in a combobox.
First i decrypt the file and read the file-content into a string. There i'm looking for all font objects. It's fast enough for big files, too.

Best regards,
Ingo
Back to Top
StanMarshall View Drop Down
Beginner
Beginner


Joined: 11 Jan 06
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote StanMarshall Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jan 06 at 11:04AM

Thanks for the idea Ingo. I'll play around with that.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store