ConvertToPDFA(Stream,PdfConversionConformance,Boolean,Boolean,Int32) Method
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.
'Declaration
Public Overloads Function ConvertToPDFA( _
ByVal As Stream, _
ByVal As PdfConversionConformance, _
ByVal As Boolean, _
ByVal As Boolean, _
Optional ByVal As Integer _
) As 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.
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();
}