Xamarin.Android

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfTrueTypeFont

    Show / Hide Table of Contents

    Class PdfTrueTypeFont

    Represents TrueType font.

    Inheritance
    System.Object
    PdfFont
    PdfTrueTypeFont
    Implements
    System.IDisposable
    Inherited Members
    PdfFont.s_syncObject
    PdfFont.MeasureString(String)
    PdfFont.MeasureString(String, PdfStringFormat)
    PdfFont.MeasureString(String, PdfStringFormat, Int32, Int32)
    PdfFont.MeasureString(String, Single)
    PdfFont.MeasureString(String, Single, PdfStringFormat)
    PdfFont.MeasureString(String, Single, PdfStringFormat, Int32, Int32)
    PdfFont.MeasureString(String, SizeF)
    PdfFont.MeasureString(String, SizeF, PdfStringFormat)
    PdfFont.MeasureString(String, SizeF, PdfStringFormat, Int32, Int32)
    PdfFont.SetStyle(PdfFontStyle)
    PdfFont.ApplyFormatSettings(String, PdfStringFormat, Single)
    PdfFont.Name
    PdfFont.Size
    PdfFont.Height
    PdfFont.Style
    PdfFont.Bold
    PdfFont.Italic
    PdfFont.Strikeout
    PdfFont.Underline
    Namespace: Syncfusion.Pdf.Graphics
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public class PdfTrueTypeFont : PdfFont, IPdfWrapper, IPdfCache, IDisposable
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add a page to the document.
    PdfPage page = document.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics;
    //Create new system font.
    Font sFont = new Font("Arial", 12, FontStyle.Regular);
    //Create a new PDF true type font instance.
    PdfFont font = new PdfTrueTypeFont(sFont);
    //Draw string to PDF page.
    graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add a page to the document.
    Dim page As PdfPage = document.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics
    'Create new system font.
    Dim sFont As New Font("Arial", 12, FontStyle.Regular)
    'Create a new PDF true type font instance.
    Dim font As PdfFont = New PdfTrueTypeFont(sFont)
    'Draw string to PDF page.
    graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    Constructors

    PdfTrueTypeFont(PdfTrueTypeFont, Single)

    Initializes a new instance of the PdfTrueTypeFont class with prototype and it's size

    Declaration
    public PdfTrueTypeFont(PdfTrueTypeFont prototype, float size)
    Parameters
    Type Name Description
    PdfTrueTypeFont prototype

    The PdfTrutypeFont using as a prototype.

    System.Single size

    The size of the font.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add a page to the document.
    PdfPage page = document.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics;     
    //Create a new PDF true type font instance.
    PdfFont font = new PdfTrueTypeFont(new PdfTrueTypeFont(new Font("Arial",12,FontStyle.Regular)), 12);
    //Draw string to PDF page.
    graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add a page to the document.
    Dim page As PdfPage = document.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics       
    'Create a new PDF true type font instance.
    Dim font As PdfFont = New PdfTrueTypeFont(New PdfTrueTypeFont(New Font("Arial",12,FontStyle.Regular)), 12)
    'Draw string to PDF page.
    graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    PdfTrueTypeFont(Stream, Boolean, PdfFontStyle, Single)

    Initializes a new instance of the PdfTrueTypeFont class.

    Declaration
    public PdfTrueTypeFont(Stream fontStream, bool embed, PdfFontStyle style, float size)
    Parameters
    Type Name Description
    System.IO.Stream fontStream
    System.Boolean embed

    Embedded.

    PdfFontStyle style

    The style.

    System.Single size

    The size.

    PdfTrueTypeFont(Stream, Single)

    Initializes a new instance of the PdfTrueTypeFont class.

    Declaration
    public PdfTrueTypeFont(Stream fontStream, float size)
    Parameters
    Type Name Description
    System.IO.Stream fontStream
    System.Single size

    The size.

    PdfTrueTypeFont(Stream, Single, PdfFontStyle)

    Initializes a new instance of the PdfTrueTypeFont class.

    Declaration
    public PdfTrueTypeFont(Stream fontStream, float size, PdfFontStyle style)
    Parameters
    Type Name Description
    System.IO.Stream fontStream
    System.Single size

    The size.

    PdfFontStyle style

    The style.

    PdfTrueTypeFont(Stream, Single, Boolean, Boolean)

    Initializes a new instance of the PdfTrueTypeFont class.

    Declaration
    public PdfTrueTypeFont(Stream fontStream, float size, bool embed, bool subset)
    Parameters
    Type Name Description
    System.IO.Stream fontStream

    The font file.

    System.Single size

    The size of the font.

    System.Boolean embed

    Embed font.

    System.Boolean subset

    Subset font.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add a page to the document.
    PdfPage page = document.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics; 
    //Read a font file stream.
    Stream fontStream = new MemoryStream(File.ReadAllBytes("arial.ttf"));
    //Create a new PDF true type font instance.
    PdfFont font = new PdfTrueTypeFont(fontStream, 12, true, false);
    //Draw string to PDF page.
    graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add a page to the document.
    Dim page As PdfPage = document.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics   
    'Read a font file stream.
    Dim fontStream As Stream = New MemoryStream(File.ReadAllBytes("arial.ttf"))
    'Create a new PDF true type font instance.
    Dim font As PdfFont = New PdfTrueTypeFont(fontStream, 12, true, false)
    'Draw string to PDF page.
    graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    Fields

    s_rtlRenderLock

    Create Instance of the rtl render lock.

    Declaration
    protected static object s_rtlRenderLock
    Field Value
    Type Description
    System.Object

    Properties

    Unicode

    Gets a value indicating whether this PdfTrueTypeFont is Unicode enabled (Read only).

    Declaration
    public bool Unicode { get; }
    Property Value
    Type Description
    System.Boolean

    true if Unicode; otherwise, false.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add a page to the document.
    PdfPage page = document.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics;
    //Create new system font.
    Font sFont = new Font("Arial", 12, FontStyle.Regular);
    //Create a new PDF true type font instance.
    PdfTrueTypeFont font = new PdfTrueTypeFont(sFont, 12, true);
    //Check unicode support.
    bool isUnicode = font.Unicode;
    //Draw string to PDF page.
    graphics.DrawString("Unicode Font = " + isUnicode, font, PdfBrushes.Black, PointF.Empty);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add a page to the document.
    Dim page As PdfPage = document.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics
    'Create new system font.
    Dim sFont As New Font("Arial", 12, FontStyle.Regular)
    'Create a new PDF true type font instance.
    Dim font As PdfTrueTypeFont = New PdfTrueTypeFont(sFont, 12, True)
    'Check unicode support.
    Dim isUnicode As Boolean = font.Unicode
    'Draw string to PDF page.
    graphics.DrawString("Unicode Font = " + isUnicode, font, PdfBrushes.Black, PointF.Empty)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    Methods

    Dispose()

    Releases all resources of the font.

    Declaration
    public void Dispose()
    Remarks

    Don't dispose the font until the corresponding document is closed.

    EqualsToFont(PdfFont)

    Checks whether fonts are equals.

    Declaration
    protected override bool EqualsToFont(PdfFont font)
    Parameters
    Type Name Description
    PdfFont font

    Font to compare.

    Returns
    Type Description
    System.Boolean

    True if fonts are equal, False otherwise.

    Overrides
    PdfFont.EqualsToFont(PdfFont)

    Finalize()

    Releases unmanaged resources and performs other cleanup operations before the PdfTrueTypeFont is reclaimed by garbage collection.

    Declaration
    protected override void Finalize()

    GetCharWidth(Char, PdfStringFormat)

    Returns width of the char.

    Declaration
    protected override float GetCharWidth(char charCode, PdfStringFormat format)
    Parameters
    Type Name Description
    System.Char charCode

    Char symbol.

    PdfStringFormat format

    String format.

    Returns
    Type Description
    System.Single

    Width of the symbol.

    Overrides
    PdfFont.GetCharWidth(Char, PdfStringFormat)

    GetLineWidth(String, PdfStringFormat)

    Returns width of the line.

    Declaration
    protected override float GetLineWidth(string line, PdfStringFormat format)
    Parameters
    Type Name Description
    System.String line

    Text line.

    PdfStringFormat format

    String format.

    Returns
    Type Description
    System.Single

    Width of the line.

    Overrides
    PdfFont.GetLineWidth(String, PdfStringFormat)

    Implements

    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved