Class PDFHighlighter
java.lang.Object
org.apache.pdfbox.contentstream.PDFStreamEngine
org.apache.pdfbox.text.PDFTextStripper
org.apache.pdfbox.examples.util.PDFHighlighter
public class PDFHighlighter
extends org.apache.pdfbox.text.PDFTextStripper
Highlighting of words in a PDF document with an XML file.
- Author:
- slagraulet (slagraulet@cardiweb.com), Ben Litchfield
- See Also:
-
Field Summary
Fields inherited from class org.apache.pdfbox.text.PDFTextStripper
charactersByArticle, document, LINE_SEPARATOR, output -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected floatcomputeFontHeight(org.apache.pdfbox.pdmodel.font.PDFont arg0) protected voidendPage(org.apache.pdfbox.pdmodel.PDPage pdPage) voidgenerateXMLHighlight(org.apache.pdfbox.pdmodel.PDDocument pdDocument, String[] sWords, Writer xmlOutput) Generate an XML highlight string based on the PDF.voidgenerateXMLHighlight(org.apache.pdfbox.pdmodel.PDDocument pdDocument, String highlightWord, Writer xmlOutput) Generate an XML highlight string based on the PDF.static voidCommand line application.protected voidshowGlyph(org.apache.pdfbox.util.Matrix arg0, org.apache.pdfbox.pdmodel.font.PDFont arg1, int arg2, org.apache.pdfbox.util.Vector arg3) Methods inherited from class org.apache.pdfbox.text.PDFTextStripper
beginMarkedContentSequence, endArticle, endDocument, endMarkedContentSequence, getAddMoreFormatting, getArticleEnd, getArticleStart, getAverageCharTolerance, getCharactersByArticle, getCurrentPageNo, getDropThreshold, getEndBookmark, getEndPage, getIgnoreContentStreamSpaceGlyphs, getIndentThreshold, getLineSeparator, getListItemPatterns, getOutput, getPageEnd, getPageStart, getParagraphEnd, getParagraphStart, getSeparateByBeads, getSortByPosition, getSpacingTolerance, getStartBookmark, getStartPage, getSuppressDuplicateOverlappingText, getText, getWordSeparator, matchPattern, processPage, processPages, processTextPosition, setAddMoreFormatting, setArticleEnd, setArticleStart, setAverageCharTolerance, setDropThreshold, setEndBookmark, setEndPage, setIgnoreContentStreamSpaceGlyphs, setIndentThreshold, setLineSeparator, setListItemPatterns, setPageEnd, setPageStart, setParagraphEnd, setParagraphStart, setShouldSeparateByBeads, setSortByPosition, setSpacingTolerance, setStartBookmark, setStartPage, setSuppressDuplicateOverlappingText, setWordSeparator, startArticle, startArticle, startDocument, startPage, writeCharacters, writeLineSeparator, writePage, writePageEnd, writePageStart, writeParagraphEnd, writeParagraphSeparator, writeParagraphStart, writeString, writeString, writeText, writeWordSeparatorMethods inherited from class org.apache.pdfbox.contentstream.PDFStreamEngine
addOperator, applyTextAdjustment, beginText, decreaseLevel, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, isShouldProcessColorOperators, markedContentPoint, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showForm, showText, showTextString, showTextStrings, showTransparencyGroup, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
-
Constructor Details
-
PDFHighlighter
Default constructor.- Throws:
IOException- If there is an error constructing this class.
-
-
Method Details
-
generateXMLHighlight
public void generateXMLHighlight(org.apache.pdfbox.pdmodel.PDDocument pdDocument, String highlightWord, Writer xmlOutput) throws 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:
IOException- If there is an error reading from the PDF, or writing to the XML.
-
generateXMLHighlight
public void generateXMLHighlight(org.apache.pdfbox.pdmodel.PDDocument pdDocument, String[] sWords, Writer xmlOutput) throws 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:
IOException- If there is an error reading from the PDF, or writing to the XML.
-
endPage
- Overrides:
endPagein classorg.apache.pdfbox.text.PDFTextStripper- Throws:
IOException
-
main
Command line application.- Parameters:
args- The command line arguments to the application.- Throws:
IOException- If there is an error generating the highlight file.
-
showGlyph
protected void showGlyph(org.apache.pdfbox.util.Matrix arg0, org.apache.pdfbox.pdmodel.font.PDFont arg1, int arg2, org.apache.pdfbox.util.Vector arg3) throws IOException - Overrides:
showGlyphin classorg.apache.pdfbox.contentstream.PDFStreamEngine- Throws:
IOException
-
computeFontHeight
- Throws:
IOException
-