// Convert a PDF document to PDF/A-2B (2011).
private void SavePdfDocumentAsPDFA2B2011(ImGearPDFDocument pdfDocument, string outputFilePathName)
{
// Create an ImGearPDFPreflight object from the source ImGearPDFDocument object, pdfDocument.
using ImGearPDFPreflight preflight = new ImGearPDFPreflight(pdfDocument);
// Create an ImGearPDFPreflightConversionOptions object for profile PDF/A-2B
// with 300 DPI fallback rasterization resolution.
using ImGearPDFPreflightConversionOptions options = new ImGearPDFPreflightConversionOptions(
ImGearPDFPreflightProfile.PDFA_2B_2011, 300);
// Attempt to create a new ImGearPDFDocument object from pdfDoc that is PDF/A-2B compliant.
ImGearPDFPreflightConversionResult result = preflight.Convert(options);
try
{
// Save the resulting PDF/A-2B compliant ImGearPDFDocument to a file.
if (result.Succeeded)
{
using Stream stream = new FileStream(outputFilePathName, FileMode.Create, FileAccess.Write);
result.Document.Save(stream, ImGearSavingFormats.PDF, 0, 0, (int)ImGearPDFPageRange.ALL_PAGES,
ImGearSavingModes.OVERWRITE);
}
}
finally
{
// Dispose of the resulting ImGearPDFDocument.
result.Document?.Dispose();
}
}