public class PdfOptimizer extends Object
AbstractOptimizationHandler
instances. Optimizer requires fully populated instance of PdfDocument
to perform valid optimization. Processing of raw PdfDocument without all the calculations done may lead to unexpected and incorrect behaviour. That is why it is only allowed to pass the source of Pdf file instead of PdfDocument instance itself.
Constructor and Description |
---|
PdfOptimizer()
Creates a new instance of PdfOptimizer, the main entry point of the optimization process.
|
Modifier and Type | Method and Description |
---|---|
PdfOptimizer |
addOptimizationHandler(AbstractOptimizationHandler handler)
Appends provided instance of AbstractOptimizationHandler to the current handler chain.
|
OptimizationResult |
optimize(File inputFile, File outputFile)
Reads PdfDocument from provided File and writes its optimized version in the new file.
|
OptimizationResult |
optimize(File inputFile, OutputStream outputStream)
|
OptimizationResult |
optimize(InputStream inputStream, File outputFile)
Reads PdfDocument from provided InputStream and writes its optimized version in the new file.
|
OptimizationResult |
optimize(InputStream inputStream, OutputStream outputStream)
Reads PdfDocument from provided InputStream and writes its optimized version in the provided OutputStream .
|
OptimizationResult |
optimize(com.itextpdf.kernel.pdf.PdfReader reader, File outputFile)
Reads PdfDocument from provided PdfReader and writes its optimized version in the new file.
|
OptimizationResult |
optimize(com.itextpdf.kernel.pdf.PdfReader reader, OutputStream outputStream)
Reads PdfDocument from provided PdfReader and writes its optimized version in the provided OutputStream .
|
void |
setReportBuilder(DefaultReportBuilder reportBuilder)
Sets a custom instance of DefaultReportBuilder .
|
public PdfOptimizer()
public PdfOptimizer addOptimizationHandler(AbstractOptimizationHandler handler)
AbstractOptimizationHandler
to the current handler chain.
handler
- is an optimization handler
public void setReportBuilder(DefaultReportBuilder reportBuilder)
DefaultReportBuilder
.
reportBuilder
- is a report builder
public OptimizationResult optimize(File inputFile, File outputFile) throws IOException
PdfDocument
from provided File
and writes its optimized version in the new file.
inputFile
- is a source of the PDF document
outputFile
- is a file where optimized document will be stored
OptimizationResult
IOException
- if any input/output issue occurs
public OptimizationResult optimize(File inputFile, OutputStream outputStream) throws IOException
inputFile
- is a source of the PDF document
outputStream
- is an output stream for optimized document
OptimizationResult
IOException
- if any input/output issue occurs
public OptimizationResult optimize(InputStream inputStream, File outputFile) throws IOException
PdfDocument
from provided InputStream
and writes its optimized version in the new file.
inputStream
- is a source of the PDF document
outputFile
- is a file where optimized document will be stored
OptimizationResult
IOException
- if any input/output issue occurs
public OptimizationResult optimize(InputStream inputStream, OutputStream outputStream) throws IOException
PdfDocument
from provided InputStream
and writes its optimized version in the provided OutputStream
.
inputStream
- is a source of the PDF document
outputStream
- is an output stream for optimized document
OptimizationResult
IOException
- if any input/output issue occurs
public OptimizationResult optimize(com.itextpdf.kernel.pdf.PdfReader reader, File outputFile) throws IOException
PdfDocument
from provided PdfReader
and writes its optimized version in the new file.
reader
- is a source of the PDF document
outputFile
- is a file where optimized document will be stored
OptimizationResult
IOException
- if any input/output issue occurs
public OptimizationResult optimize(com.itextpdf.kernel.pdf.PdfReader reader, OutputStream outputStream) throws IOException
PdfDocument
from provided PdfReader
and writes its optimized version in the provided OutputStream
.
reader
- is a source of the PDF document
outputStream
- is an output stream for optimized document
OptimizationResult
IOException
- if any input/output issue occurs
Copyright © 1998–2022 iText Group NV. All rights reserved.