How do I check for embedded fonts in a PDF document?

Question:
How do I check for embedded fonts in a PDF document?

Answer:
You can check over the embedded fonts within a PDF by looking over the the individual SDF (https://www.pdftron.com/documentation/core/guides/features/low-level/sdf/) objects within a PDF document.

The PDFTron SDK contains methods to identify which SDF objects are fonts and which of those of those fonts are embedded. The sample below will iterate over an entire document and display all embedded fonts contained in that document using C# pseudocode.

using (PDFDoc doc = new PDFDoc("YOUR_DOCUMENT_HERE"))
{
doc.InitSecurityHandler();
SDFDoc sdfdoc = doc.GetSDFDoc();

for (int i = 1; i < sdfdoc.XRefSize(); ++i)
{
Obj indirectObj = sdfdoc.GetObj(i);

if (indirectObj.IsFree()) continue;
if (!indirectObj.IsDict() && !indirectObj.IsStream()) continue;

string typeName = "";
string subtypeName = "";

Obj typeObj = indirectObj.FindObj("Type");

if (typeObj == null || !typeObj.IsName()) continue;

typeName = typeObj.GetName();

if (typeName.CompareTo("Font") != 0) continue;

Obj subtypeObj = indirectObj.FindObj("Subtype");

if (subtypeObj != null && subtypeObj.IsName())
{
subtypeName = subtypeObj.GetName();
// handle on the parent font, not this, which is the descendant font
if (subtypeName.CompareTo("CIDFontType0") == 0) continue;
}

Font font = new Font(indirectObj);
if (font.IsEmbedded())
{
string s = String.Format("Obj#{0} {1}", i, font.GetName());
Console.WriteLine(s);
}
}
}