Descendant CIDFont name if this is a Type 0 font.
public string DescendantCID {get; set;}
public String getDescendantCID();
public void setDescendantCID(
java.lang.String string
);
public:
property String^ DescendantCID
{
String^ get()
void set(String^ value)
}
DescendantCID # get and set (PDFFont)
Descendant CIDFont name if this is a Type 0 font.
PDFFont matches the font properties from PDF specification.
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;
}
import java.io.BufferedWriter;
import java.io.Console;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.Buffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.xml.validation.Schema;
import org.apache.lucene.store.Directory;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.barcode.*;
import leadtools.codecs.*;
import leadtools.pdf.*;
import leadtools.svg.*;
public void pdfDocumentFontsExample() {
// Make a copy of 'leadtools.pdf' installed with LEADTOOLS
String pdfFile = "C:\\LEADTOOLS23\\Resources\\Images\\leadtools.pdf";
PDFDocument document = new PDFDocument(pdfFile);
document.parseDocumentStructure(PDFParseDocumentStructureOptions.FONTS.getValue());
assertTrue(!document.getFonts().isEmpty());
System.out.println("Fonts found in the document:");
for (PDFFont font : document.getFonts()) {
String faceName = getPDFFontFaceName(font);
String type = getPDFFontTypeName(font);
String encoding = getPDFFontEncodingName(font);
System.out.println("Face name:" + faceName + "\n type:" + type + " encoding:" + encoding);
}
}
private static String getPDFFontFaceName(PDFFont font) {
if (font.getFaceName().equals(null))
return "";
String faceName = font.getFaceName();
// Strip out everything between + and -
char separator = '+';
int index = faceName.indexOf(separator);
if (index != -1) {
faceName = faceName.substring(index + 1);
index = faceName.indexOf(separator);
if (index != -1)
faceName = faceName.substring(0, index);
}
separator = '-';
index = faceName.indexOf(separator);
if (index != -1) {
faceName = faceName.substring(index + 1);
index = faceName.indexOf(separator);
if (index != -1)
faceName = faceName.substring(0, index);
}
if (font.getEmbeddingType().equals("Embedded")) {
faceName += " (Embedded)";
} else if (font.getEmbeddingType().equals("EmbeddedSubset")) {
faceName += " (Embedded Subset)";
}
return faceName;
}
private static String getPDFFontTypeName(PDFFont font) {
if (font.getFontType().equals(null))
return "";
if (PDFFont.TYPE_TYPE0.equals(font.getFontType())) {
if (PDFFont.TYPE_CID_FONT_TYPE2.equals(font.getDescendantCID()))
return "TrueType (CID)";
else
return "Type 2 (CID)";
}
if (PDFFont.TYPE_TYPE1.equals(font.getFontType()))
return "Type 1";
if (PDFFont.TYPE_TYPE3.equals(font.getFontType()))
return "Type 3";
return font.getFontType();
}
private static String getPDFFontEncodingName(PDFFont font) {
if (font.getEncoding().equals(null))
return "Custom";
if (PDFFont.ENCODING_WIN_ANSI_ENCODING.equals(font.getEncoding()))
return "Ansi";
if (PDFFont.ENCODING_STANDARD_ENCODING.equals(font.getEncoding()))
return "Standard";
if (PDFFont.ENCODING_PDF_DOC_ENCODING.equals(font.getEncoding()))
return "PDF";
if (PDFFont.ENCODING_MAC_EXPERT_ENCODING.equals(font.getEncoding()))
return "MAC Expert";
if (PDFFont.ENCODING_MAC_ROMAN_ENCODING.equals(font.getEncoding()))
return "MAC Roman";
return font.getEncoding();
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document