ConversionResult Class
Contains the result of PDF/A or PDF/UA conversion.
Declaration
public class ConversionResult extends JavaObject
Remarks
PdfDocument.convertToPdfA(compatibility) and PdfDocument.convertToPdfUA(compatibility) methods return a ConversionResult object. Call the getStatus() method to get the conversion status. Call the getIssues() method to get changes that the API made and issues that the API cannot fix.
Refer to the following help topic for additional information: Convert and Validate PDF/A and PDF/UA Documents — PDF Document API for Java.
Example
Convert a PDF Document to PDF/A-3b
The following code snippet converts a document to PDF/A-3b, prints conversion issues, and saves the document if the conversion completes without errors:
import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.pdf.*;
public class Main {
public static void main(String[] args) throws Exception {
Files.createDirectories(Path.of("output"));
try (InputStream inputStream = Files.newInputStream(Path.of("Document.pdf"));
PdfDocument pdfDocument = new PdfDocument(inputStream)) {
// Convert the document to PDF/A-3b.
ConversionResult result = pdfDocument.convertToPdfA(PdfACompatibility.PDF_A3B);
// Print conversion issues.
System.out.println("Conversion status: " + result.getStatus());
for (ComplianceIssue issue : result.getIssues())
System.out.println(issue.getSeverity() + ": " + issue.getMessage());
// Save the document if the conversion completed without errors.
if (result.getStatus() != ConversionStatus.ERRORS) {
try (OutputStream outputStream = Files.newOutputStream(Path.of("output", "Document.pdf"))) {
pdfDocument.save(outputStream);
}
}
}
}
}
Inherited Members
Inheritance
Methods
getIssues() Method
Returns issues that the API found or fixed during conversion.
Declaration
public List<ComplianceIssue> getIssues()
Returns
| Type | Description |
|---|---|
| java.util.List<ComplianceIssue> | Compliance issues. |
getStatus() Method
Returns the conversion status.
Declaration
public ConversionStatus getStatus()
Returns
| Type | Description |
|---|---|
| ConversionStatus | The conversion status. |
Remarks
The status reflects the most severe issue in the getIssues() list. If the list contains information messages only or no issues, the status is SUCCESS.
If the status is ERRORS, the API did not convert the document (for example, the target conformance level is not supported), or the converted document may not conform to the standard.
The getStatus() method returns the following values:
| Value | Description |
|---|---|
| SUCCESS | The conversion completed. The conversion result does not contain errors or warnings. |
| WARNINGS | The conversion completed with warnings (for example, the API removed annotations or encryption). |
| ERRORS | The API did not convert the document, or the converted document may not conform to the standard. |