GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / AddStandardFont Method
The predefined name of the required standard font. A member of the PdfStandardFont enumeration.
Example





In This Topic
AddStandardFont Method (GdPicturePDF)
In This Topic
Adds a standard font, one of the standard 14 fonts (Standard Type 1 Fonts), to the currently loaded PDF document. You need to specify the name of the font according to your preference.

PDF prescribes a set of 14 standard fonts that can be used without prior definition. These include four faces each of three Latin text typefaces (Courier, Helvetica, And Times), as well as two symbolic fonts (Symbol And ITC ZapfDingbats®). These fonts, or suitable substitute fonts with the same metrics, are required to be available in all PDF consumer applications.

Syntax
'Declaration
 
Public Function AddStandardFont( _
   ByVal StdFont As PdfStandardFont _
) As String
public string AddStandardFont( 
   PdfStandardFont StdFont
)
public function AddStandardFont( 
    StdFont: PdfStandardFont
): String; 
public function AddStandardFont( 
   StdFont : PdfStandardFont
) : String;
public: string* AddStandardFont( 
   PdfStandardFont StdFont
) 
public:
String^ AddStandardFont( 
   PdfStandardFont StdFont
) 

Parameters

StdFont
The predefined name of the required standard font. A member of the PdfStandardFont enumeration.

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 one of the standard fonts to the newly created PDF document. The font resource name is subsequently used to draw some text on the newly created page.
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 fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
     status = gdpicturePDF.GetStat()
     If status = GdPictureStatus.OK Then
        If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawText(fontResName, 10, 50, "Here is some text") = GdPictureStatus.OK) Then
            status = gdpicturePDF.SaveToFile("test_AddStandardFont.pdf")
            If status = GdPictureStatus.OK Then
                MessageBox.Show("Your prefered standard font has been successfully added and used in the newly created document.", "Example: AddStandardFont")
            End If
        Else
            status = gdpicturePDF.GetStat()
        End If
    Else
        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), "Example: AddStandardFont")
        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(), "Example: AddStandardFont")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
    string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawText(fontResName, 10, 50, "Here is some text") == GdPictureStatus.OK))
        {
            status = gdpicturePDF.SaveToFile("test_AddStandardFont.pdf");
            if (status == GdPictureStatus.OK)
                MessageBox.Show("Your prefered standard font has been successfully added and used in the newly created document.", "Example: AddStandardFont");
        }
        else
            status = gdpicturePDF.GetStat();
    }
    else
    {
        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), "Example: AddStandardFont");
        status = GdPictureStatus.OK;
    }
}
if (status != GdPictureStatus.OK)
    MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), "Example: AddStandardFont");
gdpicturePDF.Dispose();
See Also