←Select platform

PDFFontStyle Enumeration

Summary
Specifies the styles of a PDF font.
Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
[FlagsAttribute()] 
public enum PDFFontStyle 
public final class PDFFontStyle 
    extends java.lang.Enum<PDFFontStyle> 
[FlagsAttribute()] 
[SerializableAttribute()] 
public enum class PDFFontStyle  
class PDFFontStyle(Enum): 
   Normal = 0 
   Bold = 1 
   Italic = 2 
   Underline = 4 
Members
ValueMemberDescription
0x00000000Normal Normal font
0x00000001Bold Bold font
0x00000002Italic Italic font
0x00000004Underline Underline font
Remarks

The PDFFontStyle is used as the type for the PDFFont.FontStyle property.

The members of PDFFontStyle can be OR'ed together.

You can read the fonts of a PDF page through the PDFDocument.ParsePages method with the PDFParsePagesOptions.Fonts as part of the options parameter. When this method returns, each PDFDocumentPage parsed will have the PDFDocumentPage.Fonts collection populated with the fonts of the page.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
using Leadtools.WinForms; 
 
 
private static void DocumentFontsExample() 
{ 
   // Make a copy of 'leadtools.pdf' installed with LEADTOOLS 
   string pdfFile = @"C:\LEADTOOLS22\Resources\Images\leadtools.pdf"; 
 
   using (var document = new PDFDocument(pdfFile)) 
   { 
      document.ParseDocumentStructure(PDFParseDocumentStructureOptions.Fonts); 
 
      Console.WriteLine("Fonts found in the document:"); 
      if (document.Fonts != null && document.Fonts.Count > 0) 
      { 
         foreach (PDFFont font in document.Fonts) 
         { 
            string faceName = GetPDFFontFaceName(font); 
            string type = GetPDFFontTypeName(font); 
            string encoding = GetPDFFontEncodingName(font); 
 
            Console.WriteLine($"  Face name:{faceName}\n    type:{type} encoding:{encoding}"); 
         } 
      } 
   } 
} 
 
private static string GetPDFFontFaceName(PDFFont font) 
{ 
   if (string.IsNullOrEmpty(font.FaceName)) 
      return string.Empty; 
 
   string faceName = font.FaceName; 
 
   // Strip out everything between + and - 
   char[] separator = { '+', '-' }; 
   int index = faceName.IndexOfAny(separator); 
   if (index != -1) 
   { 
      faceName = faceName.Substring(index + 1); 
      index = faceName.IndexOfAny(separator); 
      if (index != -1) 
         faceName = faceName.Substring(0, index); 
   } 
 
   switch (font.EmbeddingType) 
   { 
      case PDFFontEmbeddingType.Embedded: 
         faceName += " (Embedded)"; 
         break; 
 
      case PDFFontEmbeddingType.EmbeddedSubset: 
         faceName += " (Embedded Subset)"; 
         break; 
 
      case PDFFontEmbeddingType.None: 
      default: 
         break; 
   } 
 
   return faceName; 
} 
 
private static string GetPDFFontTypeName(PDFFont font) 
{ 
   if (string.IsNullOrEmpty(font.FontType)) 
      return string.Empty; 
 
   if (string.Compare(PDFFont.TypeType0, font.FontType, true) == 0) 
   { 
      if (string.Compare(PDFFont.TypeCIDFontType2, font.DescendantCID, true) == 0) 
         return "TrueType (CID)"; 
      else 
         return "Type 2 (CID)"; 
   } 
 
   if (string.Compare(PDFFont.TypeType1, font.FontType, true) == 0) 
      return "Type 1"; 
 
   if (string.Compare(PDFFont.TypeType3, font.FontType, true) == 0) 
      return "Type 3"; 
 
   return font.FontType; 
} 
 
private static string GetPDFFontEncodingName(PDFFont font) 
{ 
   if (string.IsNullOrEmpty(font.Encoding)) 
      return "Custom"; 
 
   if (string.Compare(PDFFont.EncodingWinAnsiEncoding, font.Encoding, true) == 0) 
      return "Ansi"; 
 
   if (string.Compare(PDFFont.EncodingStandardEncoding, font.Encoding, true) == 0) 
      return "Standard"; 
 
   if (string.Compare(PDFFont.EncodingPDFDocEncoding, font.Encoding, true) == 0) 
      return "PDF"; 
 
   if (string.Compare(PDFFont.EncodingMacExpertEncoding, font.Encoding, true) == 0) 
      return "MAC Expert"; 
 
   if (string.Compare(PDFFont.EncodingMacRomanEncoding, font.Encoding, true) == 0) 
      return "MAC Roman"; 
 
   return font.Encoding; 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Pdf Namespace

Help Version 22.0.2023.7.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.