C# PDF Reader Library
How to read, extract font resources from PDF file using C#
C# Demo Code to read, extract font resource from PDF file
In this C# tutorial, you will learn how to read, extract embeded font resource from PDF document using C# in ASP.NET MVC Web, Windows applications.
Extract embedded font information from the PDF file in C# code
The C# source code below will show how to read, extract all embeded font resource from PDF document in C# code.
- Get a new PDFDocument object with an existing PDF file read
- Utilize method PDFTextHandler.GetEmbeddedFontInfo() to get a List of PDFEmbedFontInfo objects, which contain all PDF embeded font information
- For each PDFEmbedFontInfo object, you will get the embed font name
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
// Open file
PDFDocument doc = new PDFDocument(inputFilePath);
// Retreive all embedded font information
List<PDFEmbedFontInfo> fontInfos = PDFTextHandler.GetEmbeddedFontInfo(doc);
// Number of embedded fonts in the document.
Console.WriteLine("Embedded Font Count: {0}", fontInfos.Count);
foreach (PDFEmbedFontInfo fontInfo in fontInfos)
{
// Font name of the embedded font.
Console.WriteLine("Font Name: {0}", fontInfo.FontName);
// Object number in the PDF file.
Console.WriteLine("Object Number: {0}", fontInfo.ObjectNumber);
}