PdfDocumentConverter Class
Converts PDF documents to PDF/A-1b, PDF/A-2b, and PDF/A-3b.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v24.2.dll
NuGet Package: DevExpress.Document.Processor
#Declaration
public class PdfDocumentConverter :
IDisposable
#Remarks
Follow the steps below to convert a PDF document to PDF/A-1b, PDF/A-2b, and PDF/A-3b:
- Create a
PdfDocumentConverter
object. - Call the Convert(PdfCompatibility) method and pass a PdfCompatibility value as a parameter.
- Call SaveDocument(String) or SaveDocument(Stream) to specify the path where the resulting document should be saved.
You can also check the conversion status of the document and see issues encountered during conversion. Use the PdfDocumentConverter.ConversionReport property to access the PdfConversionReport object.
The following code snippet converts the “PdfAConversionDemo.pdf” file to PdfA2b
format and displays the conversion status and issues in the console:
using DevExpress.Pdf;
// ...
// Obtain a file to convert.
var filePath = "PdfAConversionDemo.pdf";
var converter = new PdfDocumentConverter(filePath);
// Convert the file to the specified format.
converter.Convert(PdfCompatibility.PdfA2b);
converter.SaveDocument("PdfAConversionDemoResult.pdf");
// Specify and display a conversion report.
var status = converter.ConversionReport.ConversionStatus;
Console.WriteLine($"Status: {status}");
Console.WriteLine("Issues:");
var issues = converter.ConversionReport.Issues;
foreach (var issue in issues){
Console.WriteLine($"{issue.Severity}: {issue.Message}");
}
The image below displays the conversion report.