Rank: Member
Groups: Registered
Joined: 10/19/2017(UTC) Posts: 14  Location: North Carolina Was thanked: 1 time(s) in 1 post(s)
|
I realize that this probably is not a simple ask. But I need to determine what font a particular PdfControl uses to render its text. The best thing I seem to have come up with in searching the forums is this: https://forum.patagames....Width-of-text-in-textboxIn post #6 you outline a procedure to obtain the font. I do note that was 2 years ago, so I would just like to ask - is there any more direct way to get the font that a PdfControl uses? Thank you, Michael
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
well Code:
//Get Default appearance for the control
string da = GetDefaultAppearance(doc.FormFill.InterForm, ctrl.Field.Dictionary);
//Parse DA
float[] strokeColor, fillColor;
float fs;
FS_MATRIX m;
string tagName;
Pdfium.FPDFTOOLS_ParseDefaultAppearance(da, out strokeColor, out fillColor, out tagName, out fs, out m);
//Check acroforms dictionary for the tagName
var font = doc.FormFill.InterForm.Fonts[tagName];
internal string GetDefaultAppearance(PdfInteractiveForms InterForms, PdfTypeDictionary dict = null, int level = 0, bool checkAcroFormsDictionary = true)
{
if ((level > 128))
return "";
if (dict.ContainsKey("DA") && dict["DA"].Is<PdfTypeString>())
return dict["DA"].As<PdfTypeString>().UnicodeString;
if (dict.ContainsKey("Parent") && dict["Parent"].Is<PdfTypeDictionary>())
return GetDefaultAppearance(InterForms, dict["Parent"].As<PdfTypeDictionary>(), level++);
if (checkAcroFormsDictionary && InterForms.Dictionary != null && InterForms.Dictionary.ContainsKey("DA") && InterForms.Dictionary["DA"].Is<PdfTypeString>())
return this.InterForms.Dictionary["DA"].As<PdfTypeString>().UnicodeString;
return "";
}
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 10/19/2017(UTC) Posts: 14  Location: North Carolina Was thanked: 1 time(s) in 1 post(s)
|
Thank you for that. I'll play with it a bit and see how it turns out.
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close