Reference Guide
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. Please always use the GetStat method to determine if this method has been successful.

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

    Remarks
    Please note that this method is only allowed for use with non-encrypted documents.

    It is recommend to use the 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 oGdPicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = oGdPicturePDF.NewPDF()
    If status = GdPictureStatus.OK Then
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
         Dim fontResName As String = oGdPicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
         status = oGdPicturePDF.GetStat()
         If status = GdPictureStatus.OK Then
            If (oGdPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
               (oGdPicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
               (oGdPicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
               (oGdPicturePDF.DrawText(fontResName, 10, 50, "Here is some text") = GdPictureStatus.OK) Then
                status = oGdPicturePDF.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 = oGdPicturePDF.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
    oGdPicturePDF.Dispose()
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    GdPictureStatus status = oGdPicturePDF.NewPDF();
    if (status == GdPictureStatus.OK)
    {
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
        string fontResName = oGdPicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
        status = oGdPicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
        {
            if ((oGdPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
                (oGdPicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
                (oGdPicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
                (oGdPicturePDF.DrawText(fontResName, 10, 50, "Here is some text") == GdPictureStatus.OK))
            {
                status = oGdPicturePDF.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 = oGdPicturePDF.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");
    oGdPicturePDF.Dispose();
    See Also