Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, December 12, 2014 12:28:50 PM(UTC)

Walter  
Walter

Groups: Tech Support, Administrators
Posts: 368

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.
LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

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.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.073 seconds.