Skip to main content

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

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
com.devexpress.system.JavaObject
ConversionResult

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.