Hi Pramod,
But is there any was where I can just get all the FONTS used in a PDF?
Hi Pramod,
static void Main(string[] args)<o:p></o:p>
{<o:p></o:p>
Document pdf = new Document(myDir + “Input.pdf”);<o:p></o:p>
Dictionary<string, string> fontNames = new Dictionary<string, string>();<o:p></o:p>
for (int i = 1; i <= pdf.Pages.Count; i++)<o:p></o:p>
{<o:p></o:p>
foreach (Aspose.Pdf.Text.Font font in pdf.Pages[i].Resources.Fonts)<o:p></o:p>
{<o:p></o:p>
if(!fontNames.ContainsKey(font.FontName))<o:p></o:p>
fontNames.Add(font.FontName,font.FontName);<o:p></o:p>
<o:p></o:p>
}<o:p></o:p>
if (pdf.Pages[i].Resources.Forms.Count > 0)<o:p></o:p>
ProcessXForms(pdf.Pages[i].Resources.Forms,fontNames);<o:p></o:p>
<o:p></o:p>
}<o:p></o:p>
foreach (string fontName in fontNames.Keys)<o:p></o:p>
{<o:p></o:p>
Console.WriteLine(“Font {0} on page resource”, fontName);<o:p></o:p>
}<o:p></o:p>
pdf.Dispose();<o:p></o:p>
}
public static void ProcessXForms(Aspose.Pdf.XFormCollection forms,Dictionary<string,string> fontNames)<o:p></o:p>
{<o:p></o:p>
foreach (Aspose.Pdf.XForm form in forms)<o:p></o:p>
{<o:p></o:p>
if (form.Resources.Fonts != null)<o:p></o:p>
{<o:p></o:p>
foreach (Aspose.Pdf.Text.Font font in form.Resources.Fonts)<o:p></o:p>
{<o:p></o:p>
if (!fontNames.ContainsKey(font.FontName))<o:p></o:p>
fontNames.Add(font.FontName,font.FontName);<o:p></o:p>
}<o:p></o:p>
// recursive call <o:p></o:p>
if (form.Resources.Forms.Count > 0)<o:p></o:p>
ProcessXForms(form.Resources.Forms, fontNames);<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
<o:p> </o:p>
<o:p>Please feel free to contact us for any further assistance.</o:p>
<o:p>
</o:p>
<o:p>Best Regards,</o:p>