Class PdfUsedFont
Represents the used fonts in a PDF document.
Inheritance
Namespace: Syncfusion.Pdf.Graphics.Fonts
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfUsedFont : Object
Remarks
This API is not supported in .NET Core, WinUI, MAUI, Xamarin, and Universal Windows Platform.
Examples
//Load the existing PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
//Get the used fonts
PdfUsedFont[] fonts = ldoc.UsedFonts;
//Get the used font Names
foreach (PdfUsedFont font in fonts)
{
string usedFontName = font.Name;
}
//Close the document
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'Get the used fonts
Dim fonts As PdfUsedFont() = ldoc.UsedFonts
'Get the used font Names
For Each font As PdfUsedFont In fonts
Dim usedFontName As String = font.Name
Next
'Close the document
ldoc.Close(True)
Constructors
PdfUsedFont(PdfFont, PdfLoadedPage)
Initializes a new instance of the PdfUsedFont class.
Declaration
public PdfUsedFont(PdfFont font, PdfLoadedPage page)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | The font |
PdfLoadedPage | page | The existing PDF page |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
//Load the existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Create a new PDF font object.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create new PDF used font object.
PdfUsedFont usedFont = new PdfUsedFont(font, ldoc.Pages[0] as PdfLoadedPage);
//Get the used font name.
string name = usedFont.Name;
//Get the used font type.
PdfFontType fontType = usedFont.Type;
//Close the document.
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Create a new PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create a new PDF used font object.
Dim usedFont As PdfUsedFont = New PdfUsedFont(font, CType(ldoc.Pages(0), PdfLoadedPage))
'Get the used font name.
Dim name As String = usedFont.Name
'Get the used font style.
Dim fontType As PdfFontType = usedFont.Type
'Close the document.
ldoc.Close(True)
Properties
Name
Gets the name.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String | The name. |
Examples
//Load the existing PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Get the use fonts.
PdfUsedFont[] fonts = ldoc.UsedFonts;
//Get the used font name
string fontName = fonts[0].Name;
//Close the document.
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get the use fonts.
Dim fonts() As PdfUsedFont = ldoc.UsedFonts
'Get the used font name
Dim fontName As String = fonts(0).Name
'Close the document.
ldoc.Close(True)
Size
Gets the size.
Declaration
public float Size { get; }
Property Value
Type | Description |
---|---|
System.Single | The size. |
Remarks
This API is not supported in .NET Core, WinUI, MAUI, Xamarin, and Universal Windows Platform.
Examples
//Load the existing PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Get the use fonts.
PdfUsedFont[] fonts = ldoc.UsedFonts;
//Get the used font size
float fontSize = fonts[0].Size;
//Close the document.
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get the use fonts.
Dim fonts() As PdfUsedFont = ldoc.UsedFonts
'Get the used font size
Dim fontSize As Single = fonts(0).Size
'Close the document.
ldoc.Close(True)
Style
Gets the style.
Declaration
public PdfFontStyle Style { get; }
Property Value
Type | Description |
---|---|
PdfFontStyle | The style. |
Remarks
This API is not supported in .NET Core, WinUI, MAUI, Xamarin, and Universal Windows Platform.
Examples
//Load the existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Get the use fonts.
PdfUsedFont[] fonts = ldoc.UsedFonts;
//Get the used font style.
PdfFontStyle fontStyle = fonts[0].Style;
//Close the document.
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get the use fonts.
Dim fonts() As PdfUsedFont = ldoc.UsedFonts
'Get the used font style
Dim fontStyle As PdfFontStyle = fonts(0).Style
'Close the document.
ldoc.Close(True)
Type
Gets the type.
Declaration
public PdfFontType Type { get; }
Property Value
Type | Description |
---|---|
PdfFontType | The type. |
Remarks
This API is not supported in .NET Core, WinUI, MAUI, Xamarin, and Universal Windows Platform.
Examples
//Load the existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Get the use fonts.
PdfUsedFont[] fonts = ldoc.UsedFonts;
//Get the used font type.
PdfFontType fontType = fonts[0].Type;
//Close the document.
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get the use fonts.
Dim fonts() As PdfUsedFont = ldoc.UsedFonts
'Get the used font type
Dim fontType As PdfFontType = fonts(0).Type
'Close the document.
ldoc.Close(True)
Methods
Replace(PdfFont)
Replaces the specified new font.
Declaration
public void Replace(PdfFont fontToReplace)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | fontToReplace |
Remarks
This API is not supported in .NET Core, WinUI, MAUI, Xamarin, and Universal Windows Platform.
Examples
//Load the existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Load the existing used fonts.
PdfUsedFont[] usedFonts = ldoc.UsedFonts;
//Get the used font to be replaced.
PdfUsedFont usedFont = usedFonts[0];
//Create a new font to be replace.
PdfFont newFont = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Repace the existing font.
usedFont.Replace(newFont);
//Save the document.
ldoc.Save("output.pdf");
//Close the document.
ldoc.Close(true);
'Load the existing PDF document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Load the existing used fonts.
Dim usedFonts() As PdfUsedFont = ldoc.UsedFonts
'Get the used font to be replaced.
Dim usedFont As PdfUsedFont = usedFonts(0)
'Create a new font to be replace.
Dim newFont As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Repace the existing font.
usedFont.Replace(newFont)
'Save the document.
ldoc.Save("output.pdf")
'Close the document.
ldoc.Close(True)