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.
OutputTargetprovides default implementations forspaces(int),linebreaks(int), andtextUnit(TextUnit). Full source code of anOutputTarget subclassis 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 defaultOutputTargetimplementation.- Since:
- v1.4
- Version:
- ©2004-2025 Snowtide
- See Also:
OutputSource.pipe(OutputHandler),OutputSource.pipe(OutputHandler, com.snowtide.pdf.layout.Direction),OutputSource.pipe(OutputHandler),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 voidendBlock(Block block)Invoked when PDFxStream has finished processing a Block.voidendLine(Line line)Invoked when PDFxStream has finished processing a Line.voidendPage(Page page)Invoked when PDFxStream has finished processing a pagevoidendPDF(String pdfName, File pdfFile)Invoked when PDFxStream has finished processing a PDF.voidendSpan(Span s)Invoked when PDFxStream has finished processing aSpanvoidlinebreaks(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).voidspaces(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).voidstartBlock(Block block)Invoked when a Block is about to be processed.voidstartLine(Line line)Invoked when a Line is about to be processed.voidstartPage(Page page)Invoked when a page is about to be processed.voidstartPDF(String pdfName, File pdfFile)Invoked when a new PDF is about to be processed.voidstartSpan(Span s)Invoked when aSpanis about to be processedvoidtextUnit(TextUnit tu)Invoked when a run of characters is to be outputted, as represented by the givenTextUnitinstance.
-
-
-
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 sourceDocumentis not reading from aFileorInputStream.
-
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 thePagethat is about to be processed
-
endPage
public void endPage(Page page)
Invoked when PDFxStream has finished processing a page- Parameters:
page- a reference to thePagethat has been processed
-
startBlock
public void startBlock(Block block)
Invoked when a Block is about to be processed.- Parameters:
block- a reference to theBlockthat is about to be processed
-
endBlock
public void endBlock(Block block)
Invoked when PDFxStream has finished processing a Block.- Parameters:
block- a reference to thePagethat has been processed
-
startLine
public void startLine(Line line)
Invoked when a Line is about to be processed.- Parameters:
line- a reference to theLinethat is about to be processed
-
endLine
public void endLine(Line line)
Invoked when PDFxStream has finished processing a Line.- Parameters:
line- a reference to theLinethat has been processed
-
textUnit
public void textUnit(TextUnit tu)
Invoked when a run of characters is to be outputted, as represented by the givenTextUnitinstance.
-
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
-
-