// Stores PDF document to a file as PDFA standard.
private void SavePdfDocumentAsPDFA(ImGearPDFDocument document, ImGearPDFPreflightProfile profile, string outputFilePathName)
{
// Create object-converter.
using (ImGearPDFPreflight preflight = new ImGearPDFPreflight((ImGearPDFDocument)document))
{
ImGearPDFPreflightReport report = preflight.VerifyCompliance(profile, 0, -1);
if (report.Code == ImGearPDFPreflightReportCodes.SUCCESS)
{
// PDF document is already compliant to PDFA standard.
// Nothing is performed.
}
else
{
if (report.Status == ImGearPDFPreflightStatusCode.Fixable)
{
// Create conversion options. We need to be sure the "ig_rgb_profile.icm" color profile
// is placed in executable file directory of this application.
ImGearPDFPreflightConvertOptions conversionOptions = new ImGearPDFPreflightConvertOptions(profile, 0, -1);
// Perform the conversion.
report = preflight.Convert(conversionOptions);
if (report.Code == ImGearPDFPreflightReportCodes.SUCCESS)
{
// Store converted document to a file.
using (Stream stream = new FileStream(outputFilePathName, FileMode.Create, FileAccess.Write))
pdfDocument.Save(stream, ImGearSavingFormats.UNKNOWN, 0, 0, (int)ImGearPDFPageRange.ALL_PAGES, ImGearSavingModes.OVERWRITE);
}
else
throw new ApplicationException("PDF document cannot be converted to APDF standard.");
}
else
throw new ApplicationException("PDF document cannot be converted to APDF standard.");
}
}
}
' Stores PDF document to a file as PDFA standard.
Private Sub SavePdfDocumentAsPDFA(document As ImGearPDFDocument, profile As ImGearPDFPreflightProfile, outputFilePathName As String)
' Create object-converter.
Using preflight As New ImGearPDFPreflight(DirectCast(document, ImGearPDFDocument))
Dim report As ImGearPDFPreflightReport = preflight.VerifyCompliance(profile, 0, -1)
' PDF document is already compliant to PDFA standard.
' Nothing is performed.
If report.Code = ImGearPDFPreflightReportCodes.SUCCESS Then
Else
If report.Status = ImGearPDFPreflightStatusCode.Fixable Then
' Create conversion options. We need to be sure the "ig_rgb_profile.icm" color profile
' is placed in executable file directory of this application.
Dim conversionOptions As New ImGearPDFPreflightConvertOptions(profile, 0, -1)
' Perform the conversion.
report = preflight.Convert(conversionOptions)
If report.Code = ImGearPDFPreflightReportCodes.SUCCESS Then
' Store converted document to a file.
Using stream As Stream = New FileStream(outputFilePathName, FileMode.Create, FileAccess.Write)
pdfDocument.Save(stream, ImGearSavingFormats.UNKNOWN, 0, 0, DirectCast(ImGearPDFPageRange.ALL_PAGES, Integer), ImGearSavingModes.OVERWRITE)
End Using
Else
Throw New ApplicationException("PDF document cannot be converted to APDF standard.")
End If
Else
Throw New ApplicationException("PDF document cannot be converted to APDF standard.")
End If
End If
End Using
End Sub