Package com.pdftools.pdfa.conversion
Class Converter
- java.lang.Object
-
- com.pdftools.internal.NativeBase
-
- com.pdftools.internal.NativeObject
-
- com.pdftools.pdfa.conversion.Converter
-
public class Converter extends NativeObject
The class to convert PDF documents to PDF/A
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Converter.ConversionEvent
The event for errors, warnings, and informational messages that occur during conversionstatic interface
Converter.ConversionEventListener
Listener interface for theConverter.ConversionEvent
event.
-
Constructor Summary
Constructors Constructor Description Converter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConversionEventListener(Converter.ConversionEventListener listener)
Add a listener for theConverter.ConversionEvent
event.Document
convert(AnalysisResult analysis, Document document, Stream outStream)
Convert a document to PDF/A.Document
convert(AnalysisResult analysis, Document document, Stream outStream, ConversionOptions options)
Convert a document to PDF/A.Document
convert(AnalysisResult analysis, Document document, Stream outStream, ConversionOptions options, OutputOptions outOptions)
Convert a document to PDF/A.void
removeConversionEventListener(Converter.ConversionEventListener listener)
Remove registered listener for theConverter.ConversionEvent
event.-
Methods inherited from class com.pdftools.internal.NativeObject
equals, hashCode
-
-
-
-
Method Detail
-
addConversionEventListener
public void addConversionEventListener(Converter.ConversionEventListener listener)
Add a listener for theConverter.ConversionEvent
event.- Parameters:
listener
- Listener for theConverter.ConversionEvent
event. If a listener is added that is already registered, it is ignored.
-
removeConversionEventListener
public void removeConversionEventListener(Converter.ConversionEventListener listener)
Remove registered listener for theConverter.ConversionEvent
event.- Parameters:
listener
- Listener for theConverter.ConversionEvent
event that should be removed. If the listener is not registered, it is ignored.
-
convert
public Document convert(AnalysisResult analysis, Document document, Stream outStream) throws java.io.IOException, NotFoundException, GenericException, LicenseException, CorruptException, ConformanceException, UnsupportedFeatureException
Convert a document to PDF/A.
Note that it is highly recommended to useConverter.ConversionEventListener
to detect critical conversion events.- Parameters:
analysis
- The result of the document's analysis usingpdftools.pdfa.validation.Validator.analyze
.document
- The document to convertoutStream
- The stream where the converted document is written- Returns:
- The result of the conversion
- Throws:
LicenseException
- The license check has failed.java.lang.IllegalArgumentException
- TheoutOptions
argument is invalid.java.lang.IllegalArgumentException
- The output stream could not be opened for writing.java.lang.IllegalStateException
- Thedocument
has already been closed.java.lang.IllegalArgumentException
- Theanalysis
has already been closed, e.g. due to a previous conversion.java.lang.IllegalArgumentException
- The PDF/A version of the analysis and the conversion options do not match.java.lang.IllegalArgumentException
- Theanalysis
is not the analysis result ofdocument
.java.io.IOException
- Error reading from or writing to theoutStream
.ConformanceException
- The conformance required byoptions
cannot be achieved.- PDF/A level U: All text of the input document must be extractable.
- PDF/A level A: In addition to the requirements of level U, the input document must be tagged.
ConformanceException
- The PDF/A version of the conformances ofanalysis
andoptions
differ. The same PDF/A version must be used for the analysis and conversion.java.lang.IllegalArgumentException
- TheoutOptions
specifies document encryption, which is not allowed in PDF/A documents.GenericException
- The document cannot be converted to PDF/A.CorruptException
- The analysis has been stopped.UnsupportedFeatureException
- The document is not a PDF, but an XFA document. Seepdftools.pdf.Document.getXfa
for more information on how to detect and handle XFA documents.NotFoundException
- A required font is missing from the installed font directories.java.lang.IllegalArgumentException
- ifanalysis
isnull
java.lang.IllegalArgumentException
- ifdocument
isnull
java.lang.IllegalArgumentException
- ifoutStream
isnull
-
convert
public Document convert(AnalysisResult analysis, Document document, Stream outStream, ConversionOptions options) throws java.io.IOException, NotFoundException, GenericException, LicenseException, CorruptException, ConformanceException, UnsupportedFeatureException
Convert a document to PDF/A.
Note that it is highly recommended to useConverter.ConversionEventListener
to detect critical conversion events.- Parameters:
analysis
- The result of the document's analysis usingpdftools.pdfa.validation.Validator.analyze
.document
- The document to convertoutStream
- The stream where the converted document is writtenoptions
- The conversion options- Returns:
- The result of the conversion
- Throws:
LicenseException
- The license check has failed.java.lang.IllegalArgumentException
- TheoutOptions
argument is invalid.java.lang.IllegalArgumentException
- The output stream could not be opened for writing.java.lang.IllegalStateException
- Thedocument
has already been closed.java.lang.IllegalArgumentException
- Theanalysis
has already been closed, e.g. due to a previous conversion.java.lang.IllegalArgumentException
- The PDF/A version of the analysis and the conversion options do not match.java.lang.IllegalArgumentException
- Theanalysis
is not the analysis result ofdocument
.java.io.IOException
- Error reading from or writing to theoutStream
.ConformanceException
- The conformance required byoptions
cannot be achieved.- PDF/A level U: All text of the input document must be extractable.
- PDF/A level A: In addition to the requirements of level U, the input document must be tagged.
ConformanceException
- The PDF/A version of the conformances ofanalysis
andoptions
differ. The same PDF/A version must be used for the analysis and conversion.java.lang.IllegalArgumentException
- TheoutOptions
specifies document encryption, which is not allowed in PDF/A documents.GenericException
- The document cannot be converted to PDF/A.CorruptException
- The analysis has been stopped.UnsupportedFeatureException
- The document is not a PDF, but an XFA document. Seepdftools.pdf.Document.getXfa
for more information on how to detect and handle XFA documents.NotFoundException
- A required font is missing from the installed font directories.java.lang.IllegalArgumentException
- ifanalysis
isnull
java.lang.IllegalArgumentException
- ifdocument
isnull
java.lang.IllegalArgumentException
- ifoutStream
isnull
-
convert
public Document convert(AnalysisResult analysis, Document document, Stream outStream, ConversionOptions options, OutputOptions outOptions) throws java.io.IOException, NotFoundException, GenericException, LicenseException, CorruptException, ConformanceException, UnsupportedFeatureException
Convert a document to PDF/A.
Note that it is highly recommended to useConverter.ConversionEventListener
to detect critical conversion events.- Parameters:
analysis
- The result of the document's analysis usingpdftools.pdfa.validation.Validator.analyze
.document
- The document to convertoutStream
- The stream where the converted document is writtenoptions
- The conversion optionsoutOptions
- The output options object- Returns:
- The result of the conversion
- Throws:
LicenseException
- The license check has failed.java.lang.IllegalArgumentException
- TheoutOptions
argument is invalid.java.lang.IllegalArgumentException
- The output stream could not be opened for writing.java.lang.IllegalStateException
- Thedocument
has already been closed.java.lang.IllegalArgumentException
- Theanalysis
has already been closed, e.g. due to a previous conversion.java.lang.IllegalArgumentException
- The PDF/A version of the analysis and the conversion options do not match.java.lang.IllegalArgumentException
- Theanalysis
is not the analysis result ofdocument
.java.io.IOException
- Error reading from or writing to theoutStream
.ConformanceException
- The conformance required byoptions
cannot be achieved.- PDF/A level U: All text of the input document must be extractable.
- PDF/A level A: In addition to the requirements of level U, the input document must be tagged.
ConformanceException
- The PDF/A version of the conformances ofanalysis
andoptions
differ. The same PDF/A version must be used for the analysis and conversion.java.lang.IllegalArgumentException
- TheoutOptions
specifies document encryption, which is not allowed in PDF/A documents.GenericException
- The document cannot be converted to PDF/A.CorruptException
- The analysis has been stopped.UnsupportedFeatureException
- The document is not a PDF, but an XFA document. Seepdftools.pdf.Document.getXfa
for more information on how to detect and handle XFA documents.NotFoundException
- A required font is missing from the installed font directories.java.lang.IllegalArgumentException
- ifanalysis
isnull
java.lang.IllegalArgumentException
- ifdocument
isnull
java.lang.IllegalArgumentException
- ifoutStream
isnull
-
-