' 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