Class PDFreactor
PDFreactor converts HTML and XML documents into PDF or image.
This sample demonstrates the use of PDFreactor:
 
PDFreactor pdfReactor = new PDFreactor();
 
 Configuration config = new Configuration();
 
 //required
 config.setDocument("https://www.realobjects.com/");
 
 Result result = pdfReactor.convert(config);
 byte[] pdf = result.getDocument();
Important: On a system without a graphical environment you have to enable the headless mode by setting the appropriate system property. Please see the manual for details.
For more information please have a look at the PDFreactor manual.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionconvert(Configuration configuration) Converts the specifiedConfigurationinto PDF or image.convert(Configuration configuration, OutputStreamProvider function) Converts the specifiedConfigurationinto PDF or image and writes it intoOutputStream(s) created by the supplied function.convert(Configuration configuration, OutputStream outputStream) Converts the specifiedConfigurationinto PDF or image and writes it directly in the suppliedOutputStream.byte[]convertAsBinary(Configuration configuration) Converts the specifiedConfigurationinto PDF or image.voidconvertAsBinary(Configuration configuration, OutputStream outputStream) Converts the specifiedConfigurationinto PDF or image and writes it directly in the suppliedOutputStream.static final voidpreinit()Pre-initializes parts of PDFreactor in separate threads to improve the performance of the first conversion.
- 
Field Details- 
VERSION
 
- 
- 
Constructor Details- 
PDFreactorpublic PDFreactor()
 
- 
- 
Method Details- 
convertConverts the specified Configurationinto PDF or image.- Parameters:
- configuration- The- Configuration.
- Returns:
- The Result.
- Throws:
- PDFreactorException- If the conversion could not be completed.
 
- 
convertAsBinaryConverts the specified Configurationinto PDF or image.- Parameters:
- configuration- The- Configuration.
- Returns:
- The resulting PDF or image.
- Throws:
- PDFreactorException- If the conversion could not be completed.
 
- 
convertAsBinarypublic void convertAsBinary(Configuration configuration, OutputStream outputStream) throws PDFreactorException Converts the specified Configurationinto PDF or image and writes it directly in the suppliedOutputStream.- Parameters:
- configuration- The- Configuration.
- outputStream- The- OutputStreamto write into.
- Throws:
- PDFreactorException- If the conversion could not be completed.
 
- 
convertpublic Result convert(Configuration configuration, OutputStream outputStream) throws PDFreactorException Converts the specified Configurationinto PDF or image and writes it directly in the suppliedOutputStream.Note that the Result.getDocument()and theResult.getDocumentArray()methods will always returnnull.- Parameters:
- configuration- The- Configuration.
- outputStream- The- OutputStreamto write into.
- Returns:
- The Result.
- Throws:
- PDFreactorException- If the conversion could not be completed.
 
- 
convertpublic Result convert(Configuration configuration, OutputStreamProvider function) throws PDFreactorException Converts the specified Configurationinto PDF or image and writes it intoOutputStream(s) created by the supplied function.The supplied function must take an OutputItemImpland returns anOutputStreamThis convert method can be used to write results directly to OutputStream(s).Note that the Result.getDocument()and theResult.getDocumentArray()methods will always returnnull.Note that multiple images are generate for image Configuration.OutputFormatif Configuration.OutputFormat.setMultiImage(Boolean)is not explicitly set to false.- Parameters:
- configuration- The- Configuration.
- function- The function which creates OutputStreams.
- Returns:
- The Result.
- Throws:
- PDFreactorException- If the conversion could not be completed or the- OutputStreamcould not be created by the supplied function.
 
- 
preinitpublic static final void preinit()Pre-initializes parts of PDFreactor in separate threads to improve the performance of the first conversion. This is only relevant in environments where the performance of the first conversion is important, e.g. command-line or cloud. This method should be called as early as possible, but even calling it right before conversions improves performance. Calling this method repeatedly is fast and safe to do, as it has no further effect.
 
-