#1
Posted
:
Friday, December 12, 2014 12:23:50 PM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
The PDFDoument class allows parsing multiple different objects using the ParsePage() method, including fonts. After parsing the PDF document, the fonts will be populated in the PDFDocumentPage.Fonts collection as PDFFont objects. In case the page doesn’t have any fonts, the collection will be initialized empty. Note that you’ll need to specify PDFParsePagesOptions.Fonts in the ‘options’ parameter of the ParsePages() method to be able to parse fonts. The code looks like this:
string _inputPDF = @"C:\Users\Public\Documents\LEADTOOLS Images\Leadtools.pdf";
string _fontsPDF = @"C:\Users\Public\Documents\LEADTOOLS Images\LeadtoolsPDF_Fonts.txt";
// Open the document
using (PDFDocument _MyDocument = new PDFDocument(_inputPDF))
{
// Parse the fonts for all pages
PDFParsePagesOptions _MyOptions = PDFParsePagesOptions.Objects | PDFParsePagesOptions.Fonts;
_MyDocument.ParsePages(_MyOptions, 1, -1);
// Save the results to the text file for examining
using (StreamWriter writer = File.CreateText(_fontsPDF))
{
foreach (PDFDocumentPage _MyPage in _MyDocument.Pages)
{
writer.WriteLine("Page {0}", _MyPage.PageNumber);
IList<PDFFont> _PDFfonts = _MyPage.Fonts;
writer.WriteLine("Fonts: {0}", _PDFfonts.Count);
foreach (PDFFont font in _PDFfonts)
{
writer.WriteLine("FaceName: " + font.FaceName);
writer.WriteLine("------");
}
}
}
}Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
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.