GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / NewPDF Method / NewPDF(PdfConformance) Method
A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of a newly created PDF document.

Setting this parameter to PdfConformance.PDF does the same as what the GdPicturePDF.NewPDF method does.

Example





In This Topic
NewPDF(PdfConformance) Method
In This Topic
Prepares a brand new empty PDF document within a GdPicturePDF object. The PDF conformance level of this PDF document will be set according to the parameter specified by you.

PDF/A is an ISO-standardized version of the PDF specialized for the digital preservation of electronic documents. It is a subset of the PDF standard which excludes those PDF features that give rise to concerns about security and the ability to archive documents long term.

You will always need an object of the GdPicturePDF class to create a new common PDF or PDF/A document. Please note that a newly created GdPicturePDF object does not automatically create a new document. The created document also does not contain any pages. You are also able to reuse the created GdPicturePDF object for manipulation with another PDF document simply by calling this method again.

Syntax
'Declaration
 
Public Overloads Function NewPDF( _
   ByVal Conformance As PdfConformance _
) As GdPictureStatus
public function NewPDF( 
    Conformance: PdfConformance
): GdPictureStatus; 
public function NewPDF( 
   Conformance : PdfConformance
) : GdPictureStatus;

Parameters

Conformance
A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of a newly created PDF document.

Setting this parameter to PdfConformance.PDF does the same as what the GdPicturePDF.NewPDF method does.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
If you use the value of the PdfConformance.PDF, the toolkit will create the PDF document conformed to the lowest PDF version (version 1.3 is the minimum) based on what the output PDF document will contain.

The origin's location and the measurement unit for any newly created document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.

This method requires the PDF Processing component to run.

Example
How to create a new single page PDF/A-1a compliant document with the "Hello World" written in the middle of the first page.
Using gdpicturePDF As New GdPicturePDF()
    'A brand new empty document without any page.
    Dim status As GdPictureStatus = gdpicturePDF.NewPDF(PdfConformance.PDF_A_1a)
    If status = GdPictureStatus.OK Then
        Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            If (gdpicturePDF.NewPage(500, 500) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") = GdPictureStatus.OK) Then
                status = gdpicturePDF.SaveToFile("test_HelloWorld.pdf")
                If status = GdPictureStatus.OK Then
                    MessageBox.Show("Your new PDF document has been successfully created.", "Example: NewPDF")
                Else
                    MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: NewPDF")
                End If
            End If
        End If
        gdpicturePDF.CloseDocument()
    Else
        MessageBox.Show("The NewPDF(PdfConformance.PDF_A_1a) method has failed with the status: " + status.ToString(), "Example: NewPDF")
    End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    //A brand new empty document without any page.
    GdPictureStatus status = gdpicturePDF.NewPDF(PdfConformance.PDF_A_1a);
    if (status == GdPictureStatus.OK)
    {
        string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            if ((gdpicturePDF.NewPage(500, 500) == GdPictureStatus.OK) &&
                (gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
                (gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
                (gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") == GdPictureStatus.OK))
            {
                status = gdpicturePDF.SaveToFile("test_HelloWorld.pdf");
                if (status == GdPictureStatus.OK)
                    MessageBox.Show("Your new PDF document has been successfully created.", "Example: NewPDF");
                else
                    MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: NewPDF");
            }
        }
        gdpicturePDF.CloseDocument();
    }
    else
    {
        MessageBox.Show("The NewPDF(PdfConformance.PDF_A_1a) method has failed with the status: " + status.ToString(), "Example: NewPDF");
    }
}
See Also