SaveAsPDF(String,PdfConformance) Method
This method converts and saves (in other words, creates a brand new destination document) the currently loaded document to a PDF document according to a file path you have specified.
The PDF conformance level of the saved PDF document is set according to the parameter specified by you. Currently, this class doesn't provide a valid conversion of existing PDF documents to PDF/A documents. For more details, please see the section Remarks below.
Parameters
- FilePath
- The file path where the destination document will save. If the specified file already exists, it will be overwritten.
- Conformance
- A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of the saved PDF document.
You can use the value of the PdfConformance.PDF to save the file as a common PDF document.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a JPEG image to a single PDF document.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
gdpictureDocumentConverter.PdfImageQuality = 50
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
gdpictureDocumentConverter.PdfImageQuality = 50;
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}