Back to Devexpress

PdfDocumentConverter.Convert(PdfCompatibility) Method

officefileapi-devexpress-dot-pdf-dot-pdfdocumentconverter-dot-convert-x28-devexpress-dot-pdf-dot-pdfcompatibility-x29.md

latest3.6 KB
Original Source

PdfDocumentConverter.Convert(PdfCompatibility) Method

Converts the specified PDF document to PDF/A-1b, PDF/A-2b, and PDF/A-3b.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public void Convert(
    PdfCompatibility compatibility
)
vb
Public Sub Convert(
    compatibility As PdfCompatibility
)

Parameters

NameTypeDescription
compatibilityPdfCompatibility

The target format.

|

Example

How to: Convert a PDF File to PDF/2b format

The following code snippet converts the “PdfAConversionDemo.pdf” file to PdfA2b format and displays the conversion status and issues in the console:

csharp
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}");
}
vb
Imports DevExpress.Pdf
' ...
' Obtain a file to convert.
Private filePath = "PdfAConversionDemo.pdf"
Private 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.
Dim status = converter.ConversionReport.ConversionStatus
Console.WriteLine($"Status: {status}")
Console.WriteLine("Issues:")
Dim issues = converter.ConversionReport.Issues
For Each issue In issues
    Console.WriteLine($"{issue.Severity}: {issue.Message}")
Next issue

The image below displays the conversion report.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Convert(PdfCompatibility) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

office-file-api-in-web-api-app/CS/Controllers/PdfController.cs#L102

csharp
// Convert the file to the specified format.
converter.Convert(format);
converter.SaveDocument(result);

See Also

PdfDocumentConverter Class

PdfDocumentConverter Members

DevExpress.Pdf Namespace