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
|