GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / ConvertToPDFA Method / ConvertToPDFA(Stream,PdfConversionConformance,Boolean,Boolean,Int32) Method
A Stream object where the converted PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document.
Set this parameter to true, if you want to let the conversion engine use the page vectorization when the direct conversion is not possible. Otherwise set it to false. Vectorization produces vector based graphic elements where applicable, for example, fonts and paths, and combines them with image resources.

The recommended value is true.

Set this parameter to true, if you want to let the conversion engine use the page rasterization when the direct conversion and vectorization are not possible or allowed. Otherwise set it to false. Rasterization renders the document content using the raster (pixel-based) approach.

The recommended value is true.

Example





In This Topic
ConvertToPDFA(Stream,PdfConversionConformance,Boolean,Boolean,Int32) Method
In This Topic
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/A conformance level according to what you have specified. Please refer to this example for more details about our native PDF to PDF/A converter.

Be aware that both Vectorization and Rasterization approaches, when used, result in loss of fonts and text information because the text converts into shapes and raster images. Text information can be later recovered using OCR features.

Syntax
'Declaration
 
Public Overloads Function ConvertToPDFA( _
   ByVal Stream As Stream, _
   ByVal Conformance As PdfConversionConformance, _
   ByVal AllowVectorization As Boolean, _
   ByVal AllowRasterization As Boolean, _
   Optional ByVal TimeoutMillisec As Integer _
) As GdPictureStatus
public function ConvertToPDFA( 
    Stream: Stream;
    Conformance: PdfConversionConformance;
    AllowVectorization: Boolean;
    AllowRasterization: Boolean;
    TimeoutMillisec: Integer
): GdPictureStatus; 
public function ConvertToPDFA( 
   Stream : Stream,
   Conformance : PdfConversionConformance,
   AllowVectorization : boolean,
   AllowRasterization : boolean,
   TimeoutMillisec : int
) : GdPictureStatus;

Parameters

Stream
A Stream object where the converted PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Conformance
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document.
AllowVectorization
Set this parameter to true, if you want to let the conversion engine use the page vectorization when the direct conversion is not possible. Otherwise set it to false. Vectorization produces vector based graphic elements where applicable, for example, fonts and paths, and combines them with image resources.

The recommended value is true.

AllowRasterization
Set this parameter to true, if you want to let the conversion engine use the page rasterization when the direct conversion and vectorization are not possible or allowed. Otherwise set it to false. Rasterization renders the document content using the raster (pixel-based) approach.

The recommended value is true.

TimeoutMillisec

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
This method is only allowed for use with non-encrypted documents.

Be aware that the output stream should be open for writing and should be closed/disposed of by the user as well.

Example
How to convert the loaded PDF document to the PDF/A-1b compliant document using streams.
Dim caption As String = "Example: ConvertToPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    Dim sourceDoc As System.IO.Stream = New System.IO.FileStream("test.pdf", System.IO.FileMode.Open)
    Dim status As GdPictureStatus = gdpicturePDF.LoadFromStream(sourceDoc)
    If status = GdPictureStatus.OK Then
        Dim destDoc As System.IO.FileStream = New System.IO.FileStream("converted.pdf", System.IO.FileMode.Create)
        status = gdpicturePDF.ConvertToPDFA(destDoc, PdfConversionConformance.PDF_A_1b, True, True)
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The PDF file has been converted successfully.", caption)
        Else
            MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
        End If
        gdpicturePDF.CloseDocument()
        destDoc.Dispose()
    Else
        MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
    End If
    sourceDoc.Dispose()
End Using
string caption = "Example: ConvertToPDFA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    System.IO.Stream sourceDoc = new System.IO.FileStream("test.pdf", System.IO.FileMode.Open);
    GdPictureStatus status = gdpicturePDF.LoadFromStream(sourceDoc);
    if (status == GdPictureStatus.OK)
    {
        System.IO.FileStream destDoc = new System.IO.FileStream("converted.pdf", System.IO.FileMode.Create);
        status = gdpicturePDF.ConvertToPDFA(destDoc, PdfConversionConformance.PDF_A_1b, true, true);
        if (status == GdPictureStatus.OK)
            MessageBox.Show("The PDF file has been converted successfully.", caption);
        else
            MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
        gdpicturePDF.CloseDocument();
        destDoc.Dispose();
    }
    else
        MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
    sourceDoc.Dispose();
}
See Also