public abstract class OutputHandler
extends java.lang.Object
The base class for all PDF text event handlers. The interface defined by this class provides what can be thought of as a SAX interface for PDF text events originating from the PDFTextStream 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 spaces(int)
,
linebreaks(int)
, and textUnit(TextUnit)
. Full source code
of an OutputTarget subclass
is provided
in the standard PDFTextStream distribution
to show how PDF text events can be utilized to customize and/or decorate
the content generated by the default OutputTarget
implementation.
PDFTextStream.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 PDFTextStream has finished processing a Block.
|
void |
endLine(Line line)
Invoked when PDFTextStream has finished processing a Line.
|
void |
endPage(Page page)
Invoked when PDFTextStream has finished processing a page
|
void |
endPDF(java.lang.String pdfName,
java.io.File pdfFile)
Invoked when PDFTextStream has finished processing a PDF.
|
void |
linebreaks(int linebreakCnt)
Invoked when PDFTextStream 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 PDFTextStream 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(java.lang.String pdfName,
java.io.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(java.lang.String pdfName, java.io.File pdfFile)
pdfName
- - the 'name' of the PDF document, as provided by
PDFTextStream.getName()
}pdfFile
- - the file reference PDFTextStream is about to begin processing.
This reference may be null if the PDFTextStream instance was not created using one of the
java.io.File
- or java.io.InputStream
-based constructors.public void endPDF(java.lang.String pdfName, java.io.File pdfFile)
pdfName
- - the 'name' of the PDF document, as provided by
PDFTextStream.getName()
}pdfFile
- - the file reference PDFTextStream 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 PDFTextStream
recommends should be outputtedpublic void linebreaks(int linebreakCnt)
linebreakCnt
- - the number of line breaks that PDFTextStream
recommends should be outputted