Package org.apache.pdfbox.util
Class PDFHighlighter
- java.lang.Object
-
- org.apache.pdfbox.util.PDFStreamEngine
-
- org.apache.pdfbox.util.PDFTextStripper
-
- org.apache.pdfbox.util.PDFHighlighter
-
public class PDFHighlighter extends PDFTextStripper
Highlighting of words in a PDF document with an XML file.- Version:
- $Revision: 1.7 $
- Author:
- slagraulet (slagraulet@cardiweb.com), Ben Litchfield
- See Also:
- Adobe Highlight File Format
-
-
Field Summary
-
Fields inherited from class org.apache.pdfbox.util.PDFTextStripper
charactersByArticle, document, output, outputEncoding, systemLineSeparator
-
-
Constructor Summary
Constructors Constructor Description PDFHighlighter()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
endPage(PDPage pdPage)
End a page.void
generateXMLHighlight(PDDocument pdDocument, java.lang.String[] sWords, java.io.Writer xmlOutput)
Generate an XML highlight string based on the PDF.void
generateXMLHighlight(PDDocument pdDocument, java.lang.String highlightWord, java.io.Writer xmlOutput)
Generate an XML highlight string based on the PDF.static void
main(java.lang.String[] args)
Command line application.-
Methods inherited from class org.apache.pdfbox.util.PDFTextStripper
endArticle, endDocument, getAddMoreFormatting, getArticleEnd, getArticleStart, getAverageCharTolerance, getCharactersByArticle, getCurrentPageNo, getDropThreshold, getEndBookmark, getEndPage, getIndentThreshold, getLineSeparator, getListItemPatterns, getOutput, getPageEnd, getPageSeparator, getPageStart, getParagraphEnd, getParagraphStart, getSeparateByBeads, getSortByPosition, getSpacingTolerance, getStartBookmark, getStartPage, getSuppressDuplicateOverlappingText, getText, getText, getWordSeparator, handleLineSeparation, inspectFontEncoding, isParagraphSeparation, matchListItemPattern, matchPattern, processPage, processPages, processTextPosition, resetEngine, setAddMoreFormatting, setArticleEnd, setArticleStart, setAverageCharTolerance, setDropThreshold, setEndBookmark, setEndPage, setIndentThreshold, setLineSeparator, setListItemPatterns, setPageEnd, setPageSeparator, setPageStart, setParagraphEnd, setParagraphStart, setShouldSeparateByBeads, setSortByPosition, setSpacingTolerance, setStartBookmark, setStartPage, setSuppressDuplicateOverlappingText, setWordSeparator, startArticle, startArticle, startDocument, startPage, writeCharacters, writeLineSeparator, writePage, writePageEnd, writePageSeperator, writePageStart, writeParagraphEnd, writeParagraphSeparator, writeParagraphStart, writeString, writeString, writeText, writeText, writeWordSeparator
-
Methods inherited from class org.apache.pdfbox.util.PDFStreamEngine
getColorSpaces, getCurrentPage, getFonts, getGraphicsStack, getGraphicsState, getGraphicsStates, getResources, getTextLineMatrix, getTextMatrix, getTotalCharCnt, getValidCharCnt, getXObjects, isForceParsing, processEncodedText, processOperator, processOperator, processStream, processSubStream, registerOperatorProcessor, setColorSpaces, setFonts, setForceParsing, setGraphicsStack, setGraphicsState, setGraphicsStates, setTextLineMatrix, setTextMatrix
-
-
-
-
Method Detail
-
generateXMLHighlight
public void generateXMLHighlight(PDDocument pdDocument, java.lang.String highlightWord, java.io.Writer xmlOutput) throws java.io.IOException
Generate an XML highlight string based on the PDF.- Parameters:
pdDocument
- The PDF to find words in.highlightWord
- The word to search for.xmlOutput
- The resulting output xml file.- Throws:
java.io.IOException
- If there is an error reading from the PDF, or writing to the XML.
-
generateXMLHighlight
public void generateXMLHighlight(PDDocument pdDocument, java.lang.String[] sWords, java.io.Writer xmlOutput) throws java.io.IOException
Generate an XML highlight string based on the PDF.- Parameters:
pdDocument
- The PDF to find words in.sWords
- The words to search for.xmlOutput
- The resulting output xml file.- Throws:
java.io.IOException
- If there is an error reading from the PDF, or writing to the XML.
-
endPage
protected void endPage(PDPage pdPage) throws java.io.IOException
End a page. Default implementation is to do nothing. Subclasses may provide additional information.- Overrides:
endPage
in classPDFTextStripper
- Parameters:
pdPage
- The page we are about to process.- Throws:
java.io.IOException
- If there is any error writing to the stream.
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
Command line application.- Parameters:
args
- The command line arguments to the application.- Throws:
java.io.IOException
- If there is an error generating the highlight file.
-
-