Class OutputHandler
- java.lang.Object
-
- com.snowtide.pdf.OutputHandler
-
- Direct Known Subclasses:
GoogleHTMLOutputHandler
,OutputTarget
,RegionOutputTarget
,VisualOutputTarget
,XMLOutputTarget
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 forspaces(int)
,linebreaks(int)
, andtextUnit(TextUnit)
. Full source code of anOutputTarget 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 defaultOutputTarget
implementation.- Since:
- v1.4
- Version:
- ©2004-2024 Snowtide
- See Also:
OutputSource.pipe(OutputHandler)
,OutputSource.pipe(OutputHandler, com.snowtide.pdf.layout.Direction)
,OutputSource.pipe(OutputHandler)
,OutputSource.pipe(OutputHandler)
-
-
Constructor Summary
Constructors Constructor Description OutputHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 pagevoid
endPDF(String pdfName, File pdfFile)
Invoked when PDFxStream has finished processing a PDF.void
endSpan(Span s)
Invoked when PDFxStream has finished processing aSpan
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
startSpan(Span s)
Invoked when aSpan
is about to be processedvoid
textUnit(TextUnit tu)
Invoked when a run of characters is to be outputted, as represented by the givenTextUnit
instance.
-
-
-
Method Detail
-
startPDF
public void startPDF(String pdfName, File pdfFile)
Invoked when a new PDF is about to be processed.- Parameters:
pdfName
- the 'name' of the PDF document, as provided byDocument.getName()
}pdfFile
- the file reference PDFxStream is about to begin processing. This reference may be null if the sourceDocument
is not reading from aFile
orInputStream
.
-
endPDF
public void endPDF(String pdfName, File pdfFile)
Invoked when PDFxStream has finished processing a PDF.- Parameters:
pdfName
- the 'name' of the PDF document, as provided byDocument.getName()
}pdfFile
- the file reference PDFxStream has finished processing
-
startPage
public void startPage(Page page)
Invoked when a page is about to be processed.- Parameters:
page
- a reference to thePage
that is about to be processed
-
endPage
public void endPage(Page page)
Invoked when PDFxStream has finished processing a page- Parameters:
page
- a reference to thePage
that has been processed
-
startBlock
public void startBlock(Block block)
Invoked when a Block is about to be processed.- Parameters:
block
- a reference to theBlock
that is about to be processed
-
endBlock
public void endBlock(Block block)
Invoked when PDFxStream has finished processing a Block.- Parameters:
block
- a reference to thePage
that has been processed
-
startLine
public void startLine(Line line)
Invoked when a Line is about to be processed.- Parameters:
line
- a reference to theLine
that is about to be processed
-
endLine
public void endLine(Line line)
Invoked when PDFxStream has finished processing a Line.- Parameters:
line
- a reference to theLine
that has been processed
-
textUnit
public void textUnit(TextUnit tu)
Invoked when a run of characters is to be outputted, as represented by the givenTextUnit
instance.
-
spaces
public 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).- Parameters:
spaceCnt
- the number of spaces that PDFxStream recommends should be outputted
-
linebreaks
public 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).- Parameters:
linebreakCnt
- the number of line breaks that PDFxStream recommends should be outputted
-
-