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 - AddSubsettedFont Problems
  FAQ FAQ  Forum Search   Register Register  Login Login

AddSubsettedFont Problems

 Post Reply Post Reply
Author
Message
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Topic: AddSubsettedFont Problems
    Posted: 22 Feb 12 at 1:52PM
Hi,

I'm trying to embed a subsetted font into my document, but it doesn't seem to be working as expected.

On the source/QPDF computer, I have a font called Monaco which I add to my document using AddSubsettedFont after my document has been created and I've built a list of all the fonts and characters in use. I'm getting return handles from the AddSubsettedFont operation.

All of the text is drawn to my PDF using Windows API functions on the CanvasDC of QuickPDF (I do this because I need to draw formatted RichText using the EM_FORMATRANGE message).

When I use RenderToDC on the source computer I get the expected output, for example:


But when I view the PDF on a destination computer (in Adobe Reader) that doesn't have the font installed, I get something close but not correct:


Notice the missing serif on the "I" character, no slash in the "0", incorrect "a", etc...

Does font subsetting not work when the text is created using the CanvasDC, or maybe I need to be subsetting the fonts *before* I draw the text? Something else?

Thanks a lot in advance for any help.
Jason

Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 22 Feb 12 at 2:41PM
I've switched to AddTrueTypeSubsettedFont as per Andrew's recommendations in another thread, but I'm getting the same output as above, so still no luck.
Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 22 Feb 12 at 7:59PM
Looks like the mistake was mine - I was mysteriously using an option of 4 (which doesn't exist) in LoadFromCanvasDC instead of 2...Sorry if I've wasted your time!
Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 22 Feb 12 at 8:38PM
One problem: the resultant PDF files are now quite large (4ish MB instead of 200ish KB).

Maybe QPDF is embedding fonts even if they are in the NoEmbedFontList? Or maybe it is embedding the same font multiple time for each call that I've made to EM_FORMATRANGE on the CanvasDC?

I don't know enough about the internals of PDF files to know, but I've attached a sample PDF if anyone has the time to inspect it and tell me why it is so large. I appreciate the help.

http://www.statslog.net/fontembed.pdf


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

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 12 at 8:04AM
The PDF looks like it originally have 10 pages but these have been deleted.  Also there are multiple copies of embedded Type1 fonts such as Tahoma and Helvetica but they don't seem to be referenced anywhere.

If you load the PDF file in Notepad or some other text editor you can scroll through and see the fonts in the PDF file.




Andrew.
Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 12 at 1:56PM
The PDF is generated exclusively using QuickPDF from a proprietary template format. Let me give you some background first:

Our template/layout file format is an Sqlite database that allows users to position textboxes (RTF), data fields, lines, images, etc... anywhere on a page. There can be dozens of these objects per page. The layout, font and character possibilities are essentially endless.

We then parse this template database, merge in data from other databases and send drawing commands to QuickPDF to generate the fully rendered PDF.

In the case of RTF TextBoxes, I'm using GetCanvasDC on the first call to a RTF drawing operation, then draw the RTF to that DC. Subsequent calls to RTF drawing use the same DC unless a non-RTF drawing operation is encountered.

When an operation such as drawing an image or a line is encountered, I call LoadFromCanvasDC, then merge document to the main document, capture the page and draw it over the active page in the main document. I then process the line or image drawing operation using the QuickPDF DrawLine, DrawImage or DrawBox methods as appropriate on the active page in the main document.

These operations continue until all of the objects have been drawn on the page and the document is complete.

My guess at the 10 pages is that there are 9 times that I'm performing the LoadCanvasDC > > MergeDocument > CapturePage process (which automatically deletes the capture page, thus making it appear as if there were more pages originally).

As to where the Helvetica font came from, I have no idea - I don't even have that font on my system and I have put Helvetica in my NoEmbedFontList, so I don't know why it should have been included? Tahoma is also on my NoEmbedFontList, so it shouldn't be included either should it?

When I use LoadFromCanvasDC with an option of 2, does QuickPdf embed all of the fonts used in the DC even if they've been previously embedded? That is - is there no way for QuickPDF to notice that a font has already been embedded before it embeds it again?

Also, shouldn't LoadFromCanvasDC be honouring the NoEmbedFontList when used with an option of 2?

Lastly, does it make more sense to move this conversation to a support ticket?

Thanks a lot for your help Andrew.




Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 12 at 2:38PM
Regarding Helvetica - since it is one of the PDF standard fonts, should this mean that it should never be embedded by QuickPDF?
Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 12 at 3:21PM
I've created a small sample VB6 project that uses the features using to demonstrate the problem concisely.

It performs the following operations:
1) Creates a 100 page document
2) Each page has only the text "abcdef 0123" on it
3) Each page alternates between a font in the NoEmbedFontList ("Tahoma") and a font that we want embedded that might not be on a target system ("Monaco", but you can change this to a font you have).

This creates an almost 20MB PDF file, but ideally it would only embed the Monaco font once instead of 50 times. Is this possible to achieve with QuickPDF?

Link:
http://www.statslog.net/pdffontembed.zip
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 24 Feb 12 at 9:09AM
Have you tried option 4 with the Qpdf.NewPageFromCanvasDC 96, 4  function.

3 = Process the drawing commands as vector graphics, fonts not in the no embed
font list are embedded and compressed
4 = Same as 3 but fonts already added during previous calls to this function or the
LoadFromCanvasDC function are reused



Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 24 Feb 12 at 12:44PM
I originally had option 4 there, but I was having trouble with font embedding. I then changed it to 2 because I didn't see option 4 in the online documentation (see http://www.quickpdflibrary.com/help/quickpdf/LoadFromCanvasDC.php ) so I thought I had used it in error. I guess you must have told me to use it another time, and this time I will make sure to comment this code to avoid the problem again in the future. I've tried using option 4 again, and it appears to be working, so thank you.

What I can't explain though is why fonts seem to be embedded even if they are in the NoEmbedFontList? Is this a bug?

Also, assuming that the NoEmbedFontList is working, do I need to put entries for Bold, Italic, etc... I notice the PDF can have entries such as "Arial,Bold" and "Arial,Italic", etc... so to prevent embedding of Arial entirely, do I need to do something like:

QP.NoEmbedFontListAdd "Arial"
QP.NoEmbedFontListAdd "Arial,Bold"
QP.NoEmbedFontListAdd "Arial,Italic"
etc...

or is QP.NoEmbedFontListAdd "Arial" enough to prevent any style of Arial from being embedded?

Thanks for your help Andrew.
Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 24 Feb 12 at 12:53PM
On closer look, at least with Option 4, it doesn't appear that fonts in the NoEmbedFontList are being embedded (so that is good!)

So the only question that remains for me is if I need to add all variants of the NoEmbedFontList (Bold, Italic, etc....) to the NoEmbedFontList if I don't want them to be embedded.




Edited by jpbro - 24 Feb 12 at 1:31PM
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