GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / AddTrueTypeFontU Method / AddTrueTypeFontU(String,Boolean,Boolean,Boolean) Method
The name of the required system font to add for use in the PDF document.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
Set this parameter to true if you want to subset the font, otherwise set it to false.

Subsetting a font allows you to keep a file smaller, but note that the font subset is gradually updated with each use of the GdPicturePDF.DrawText method.

Example





In This Topic
AddTrueTypeFontU(String,Boolean,Boolean,Boolean) Method
In This Topic
Adds a TrueType or OpenType system font to the currently loaded PDF document according to a font name and other parameters you have specified. The displaying of Unicode characters is supported when using the font added by this method.
Syntax
'Declaration
 
Public Overloads Function AddTrueTypeFontU( _
   ByVal FontName As String, _
   ByVal Bold As Boolean, _
   ByVal Italic As Boolean, _
   ByVal EnableSubset As Boolean _
) As String
public string AddTrueTypeFontU( 
   string FontName,
   bool Bold,
   bool Italic,
   bool EnableSubset
)
public function AddTrueTypeFontU( 
    FontName: String;
    Bold: Boolean;
    Italic: Boolean;
    EnableSubset: Boolean
): String; 
public function AddTrueTypeFontU( 
   FontName : String,
   Bold : boolean,
   Italic : boolean,
   EnableSubset : boolean
) : String;
public: string* AddTrueTypeFontU( 
   string* FontName,
   bool Bold,
   bool Italic,
   bool EnableSubset
) 
public:
String^ AddTrueTypeFontU( 
   String^ FontName,
   bool Bold,
   bool Italic,
   bool EnableSubset
) 

Parameters

FontName
The name of the required system font to add for use in the PDF document.
Bold
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Italic
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
EnableSubset
Set this parameter to true if you want to subset the font, otherwise set it to false.

Subsetting a font allows you to keep a file smaller, but note that the font subset is gradually updated with each use of the GdPicturePDF.DrawText method.

Return Value

Returns a resource name of the specified font required for the next usage within the PDF document. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.

This resource name you can subsequently pass, for example, to the GdPicturePDF.DrawText method, as well as to all methods, which have a font resource name as a parameter.

Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Example
How to add a True Type system font with Unicode support to the newly created PDF document. The font resource name is subsequently used to draw some unicode text on the newly created page.
Dim caption As String = "Example: AddTrueTypeFontU"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
    Dim fontResNameBold As String = gdpicturePDF.AddTrueTypeFontU("MingLiu", False, False, False)
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawText(fontResNameBold, 10, 50, ChrW(20320) + "        " + ChrW(22909)) = GdPictureStatus.OK) Then
            status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontU.pdf")
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The example HAS been followed successfully.", caption)
            End If
        Else
            status = gdpicturePDF.GetStat()
        End If
    Else
        MessageBox.Show("The AddTrueTypeFontU() method has failed with the status: " + status.ToString(), caption)
        status = GdPictureStatus.OK
    End If
End If
If status <> GdPictureStatus.OK Then
    MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFontU";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
    string fontResName = gdpicturePDF.AddTrueTypeFontU("MingLiu", false, false, false);
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        string text = ((char)(20320)).ToString() + "        " + ((char)(22909)).ToString();
        if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawText(fontResName, 10, 50, text) == GdPictureStatus.OK))
        {
            status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontU.pdf");
            if (status == GdPictureStatus.OK)
                MessageBox.Show("The example HAS been followed successfully.", caption);
        }
        else
            status = gdpicturePDF.GetStat();
    }
    else
    {
        MessageBox.Show("The AddTrueTypeFontU() method has failed with the status: " + status.ToString(), caption);
        status = GdPictureStatus.OK;
    }
}
if (status != GdPictureStatus.OK)
    MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
See Also