ImageGear for .NET PDF component provides the ImGearPDFSaveOptions class that defines options for saving raster pages and documents to specific PDF formats like PDF/A. This class is derived from the regular ImGearSaveOptions class and could be used with the regular ImGearFileFormats.SavePage and ImGearFileFormats.SaveDocument methods that take ImGearSaveOptions parameter.
The following sample code demonstrates how to use the ImGearPDFSaveOptions class for saving raster document to PDF/A:
C# Example | Copy Code |
---|---|
ImGearDocument doc = null; // Load raster document. using (FileStream fileStream = new FileStream(infile, FileMode.Open, FileAccess.Read, FileShare.Read)) { doc = ImGearFileFormats.LoadDocument(fileStream, 0, -1); } // Specify PDF/A options for saving. ImGearPDFSaveOptions pdfOptions = new ImGearPDFSaveOptions(); pdfOptions.PreflightOptions = new ImGearPDFPreflightConvertOptions(ImGearPDFPreflightProfile.PDFA_1A_2005, 0, -1); pdfOptions.PreflightOptions.OutputIntentColorProfile = ImGearColorProfileManager.RgbProfile; // Save to PDF/A file. using (FileStream fileStream = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { ImGearFileFormats.SaveDocument(doc, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF_DEFLATE, pdfOptions); } |
VB.NET Example | Copy Code |
---|---|
Dim doc As ImGearDocument ' Load raster document. Using fileStream As FileStream = New FileStream(infile, FileMode.Open, FileAccess.Read, FileShare.Read) doc = ImGearFileFormats.LoadDocument(fileStream, 0, -1) End Using ' Specify PDF/A options for saving. Dim pdfOptions As ImGearPDFSaveOptions = New ImGearPDFSaveOptions() pdfOptions.PreflightOptions = New ImGearPDFPreflightConvertOptions(ImGearPDFPreflightProfile.PDFA_1A_2005, 0, -1) pdfOptions.PreflightOptions.OutputIntentColorProfile = ImGearColorProfileManager.RgbProfile ' Save to PDF/A file. Using fileStream As FileStream = New FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite) ImGearFileFormats.SaveDocument(doc, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF_DEFLATE, pdfOptions) End Using |
You can also use this approach for converting PDF files to PDF/A which would be effectively the same as using ImGearPDFPreflight.Convert for the original PDF document. |