public abstract class OutputHandler extends Object
The base class for all PDF text event handlers. The interface defined by this class provides what can be thought of as akin to the SAX interface for PDF text events originating from the PDFxStream document model: the beginning and ending of blocks, pages, lines, character output, etc. The possibilities for transforming, decorating, and filtering PDF text content based on document structure, layout, and content are significant.
OutputTarget
provides default implementations for OutputHandler.spaces(int)
,
OutputHandler.linebreaks(int)
, and OutputHandler.textUnit(TextUnit)
. Full source code
of an OutputTarget subclass
is provided
in the standard PDFxStream distribution
to show how PDF text events can be utilized to customize and/or decorate
the content generated by the default OutputTarget
implementation.
Document.pipe(OutputHandler)
,
Page.pipe(OutputHandler)
,
Block.pipe(OutputHandler)
,
Line.pipe(OutputHandler)
Constructor and Description |
---|
OutputHandler() |
Modifier and Type | Method and Description |
---|---|
void |
endBlock(Block block)
Invoked when PDFxStream has finished processing a Block.
|
void |
endLine(Line line)
Invoked when PDFxStream has finished processing a Line.
|
void |
endPage(Page page)
Invoked when PDFxStream has finished processing a page
|
void |
endPDF(String pdfName,
File pdfFile)
Invoked when PDFxStream has finished processing a PDF.
|
void |
linebreaks(int linebreakCnt)
Invoked when PDFxStream determines that a series of line breaks should
be outputted between the previous entity (page, block, line, etc) and the
next entity (page, block, line, etc).
|
void |
spaces(int spaceCnt)
Invoked when PDFxStream determines that a series of spaces should
be outputted between the previous entity (block, line, text unit, etc) and the
next entity (block, line, text unit, etc).
|
void |
startBlock(Block block)
Invoked when a Block is about to be processed.
|
void |
startLine(Line line)
Invoked when a Line is about to be processed.
|
void |
startPage(Page page)
Invoked when a page is about to be processed.
|
void |
startPDF(String pdfName,
File pdfFile)
Invoked when a new PDF is about to be processed.
|
void |
textUnit(TextUnit tu)
Invoked when a run of characters is to be outputted, as represented by the
given
TextUnit instance. |
public void startPDF(String pdfName, File pdfFile)
pdfName
- the 'name' of the PDF document, as provided by
Document.getName()
}pdfFile
- the file reference PDFxStream is about to begin processing.
This reference may be null if the source Document
is not reading from a
File
or InputStream
.public void endPDF(String pdfName, File pdfFile)
pdfName
- the 'name' of the PDF document, as provided by
Document.getName()
}pdfFile
- the file reference PDFxStream has finished processingpublic void startPage(Page page)
page
- a reference to the Page
that is about to be processedpublic void endPage(Page page)
page
- a reference to the Page
that has been processedpublic void startBlock(Block block)
block
- a reference to the Block
that is about to be processedpublic void endBlock(Block block)
block
- a reference to the Page
that has been processedpublic void startLine(Line line)
line
- a reference to the Line
that is about to be processedpublic void endLine(Line line)
line
- a reference to the Line
that has been processedpublic void textUnit(TextUnit tu)
TextUnit
instance.public void spaces(int spaceCnt)
spaceCnt
- the number of spaces that PDFxStream
recommends should be outputtedpublic void linebreaks(int linebreakCnt)
linebreakCnt
- the number of line breaks that PDFxStream
recommends should be outputted