com.snowtide.pdf
Class OutputHandler

java.lang.Object
  extended by com.snowtide.pdf.OutputHandler
Direct Known Subclasses:
GoogleHTMLOutputHandler, OutputTarget, RegionOutputTarget, VisualOutputTarget, XMLOutputTarget

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.

Since:
v1.4
Version:
©2004-2012 Snowtide Informatics Systems, Inc.
See Also:
PDFTextStream.pipe(OutputHandler), Page.pipe(OutputHandler), Block.pipe(OutputHandler), Line.pipe(OutputHandler)

Constructor Summary
OutputHandler()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputHandler

public OutputHandler()
Method Detail

startPDF

public void startPDF(java.lang.String pdfName,
                     java.io.File pdfFile)
Invoked when a new PDF is about to be processed.

Parameters:
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.

endPDF

public void endPDF(java.lang.String pdfName,
                   java.io.File pdfFile)
Invoked when PDFTextStream has finished processing a PDF.

Parameters:
pdfName - - the 'name' of the PDF document, as provided by PDFTextStream.getName() }
pdfFile - - the file reference PDFTextStream has finished processing

startPage

public void startPage(Page page)
Invoked when a page is about to be processed.

Parameters:
page - - a reference to the Page that is about to be processed

endPage

public void endPage(Page page)
Invoked when PDFTextStream has finished processing a page

Parameters:
page - - a reference to the Page that has been processed

startBlock

public void startBlock(Block block)
Invoked when a Block is about to be processed.

Parameters:
block - - a reference to the Block that is about to be processed

endBlock

public void endBlock(Block block)
Invoked when PDFTextStream has finished processing a Block.

Parameters:
block - - a reference to the Page that has been processed

startLine

public void startLine(Line line)
Invoked when a Line is about to be processed.

Parameters:
line - - a reference to the Line that is about to be processed

endLine

public void endLine(Line line)
Invoked when PDFTextStream has finished processing a Line.

Parameters:
line - - a reference to the Line that has been processed

textUnit

public void textUnit(TextUnit tu)
Invoked when a run of characters is to be outputted, as represented by the given TextUnit instance.


spaces

public 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).

Parameters:
spaceCnt - - the number of spaces that PDFTextStream recommends should be outputted

linebreaks

public 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).

Parameters:
linebreakCnt - - the number of line breaks that PDFTextStream recommends should be outputted