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 - Use embedded font of a PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Use embedded font of a PDF

 Post Reply Post Reply
Author
Message
datasportdev View Drop Down
Beginner
Beginner
Avatar

Joined: 29 Apr 15
Location: Switzerland
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote datasportdev Quote  Post ReplyReply Direct Link To This Post Topic: Use embedded font of a PDF
    Posted: 29 Apr 15 at 10:16AM
Hi
I'm trying to use an embedded font when I LoadFromFile() a PDF and then I AddTrueTypeFont() with the parameter embed = 0, because the font is already in the PDF.

But event if I read (Windows CMD --> findstr FontName "FileName") all the included font names and I take the exactly same font name or font family name, my new text does not use this font. Instead the new text is diplayed with a "default" font (Arial in my case, since the font is not installed on my PC.

What Do I do wrong??

Here a snippet:

Count := QuickPDF.FontCount;
  Found := FALSE;
  Index := 1;
  WHILE (Index <= Count) AND NOT Found DO BEGIN
    FontID := QuickPDF.GetFontID(Index);
    IF FontID > 0 then begin
      QuickPDF.SelectFont(FontID);
      if QuickPDF.FontName = FontName then Found := TRUE;
    end;
    if NOT Found then INC(Index);
  END;
  if NOT Found then begin
    FontID := QuickPDF.AddTrueTypeFont(FontName,0);
    QuickPDF.SelectFont(FontID);
  end;
Back to Top
erico View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24 Sep 14
Location: Minnesota USA
Status: Offline
Points: 51
Post Options Post Options   Thanks (1) Thanks(1)   Quote erico Quote  Post ReplyReply Direct Link To This Post Posted: 29 Apr 15 at 3:02PM
Originally posted by datasportdev datasportdev wrote:


 if NOT Found then begin
    FontID := QuickPDF.AddTrueTypeFont(FontName,0);
    QuickPDF.SelectFont(FontID);
  end;


You cannot add a font you do not have. Thus the AddTrueTypeFont call above will always fail, regardless of the embed flag unless you have the font.

If the font is already in the PDF, you should be able to use it unless it has been subsetted, in which case not all characters will be available (and probably not in the standard encoding either) so adding text would be problematic at best.
Eric O
Back to Top
datasportdev View Drop Down
Beginner
Beginner
Avatar

Joined: 29 Apr 15
Location: Switzerland
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote datasportdev Quote  Post ReplyReply Direct Link To This Post Posted: 29 Apr 15 at 4:20PM
Thx 4 ur reply.

I know that the font is embedded. My task is now to add a text with the already embedded form.
When I do FontCount the Result = 2. One is Arial and the other is the other font I need.

When I want to add a text to the loaded PDF with this second font, I get a FontId > 0 and use this ID for my text.
Yet the new text in the PDF doesn't use that embedded fobt, but a 'default' obe from the PC where the file has been opened.
Back to Top
erico View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24 Sep 14
Location: Minnesota USA
Status: Offline
Points: 51
Post Options Post Options   Thanks (1) Thanks(1)   Quote erico Quote  Post ReplyReply Direct Link To This Post Posted: 29 Apr 15 at 4:55PM
You indicate that QuickPDF.FontCount is 2. Did you check that result, or do you just believe that to be true because Acrobat says there are 2 fonts embedded? Unless you call QuickPDF.FindFonts() any fonts that are already embedded in the PDF will not be seen by QuickPDF.FontCount (Check the documentation for FontCount).

Originally posted by datasportdev datasportdev wrote:

    IF FontID > 0 then begin
      QuickPDF.SelectFont(FontID);
      if QuickPDF.FontName = FontName then Found := TRUE;
    end;


Are you positive that the FontName you specify is an exact match for QuickPDF.FontName ?
(Is Found being set to TRUE?)

Just for a test, try selecting the first font found to see if it will be used:

    FontID := QuickPDF.GetFontID(1);
    IF FontID > 0 then QuickPDF.SelectFont(FontID);
    ... add some text ...

Eric O
Back to Top
datasportdev View Drop Down
Beginner
Beginner
Avatar

Joined: 29 Apr 15
Location: Switzerland
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote datasportdev Quote  Post ReplyReply Direct Link To This Post Posted: 29 Apr 15 at 8:36PM
Sorry! Problem found!
Confused

I was comparing the FontFamily with the FontName Embarrassed
My BIG mistake!

Now everything works fine!

Thx a lot for your feedback!!


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