ConvertToPDFUA(Stream,PdfConversionConformance,Int32) Method
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/UA conformance.
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. Currently, PDF_UA_1 is the only valid option.
- 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/UA-1 compliant document using streams.
Dim caption As String = "Example: ConvertToPDFUA"
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.ConvertToPDFUA(destDoc, PdfConversionConformance.PDF_UA_1)
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: ConvertToPDFUA";
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.ConvertToPDFUA(destDoc, PdfConversionConformance.PDF_UA_1);
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();
}