Class PrintTextColors


public class PrintTextColors extends PDFTextStripper
This is an example on how to get the colors of text. Note that this will not tell the background, and will only work properly if the text is not overwritten later, and only if the text rendering modes are 0, 1 or 2. In the PDF 32000 specification, please read 9.3.6 "Text Rendering Mode" to know more. Mode 0 (FILL) is the default. Mode 1 (STROKE) will make glyphs look "hollow". Mode 2 (FILL_STROKE) will make glyphs look "fat".
  • Constructor Details

    • PrintTextColors

      public PrintTextColors() throws IOException
      Instantiate a new PDFTextStripper object.
      Throws:
      IOException - If there is an error loading the properties.
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      This will print the documents data.
      Parameters:
      args - The command line arguments.
      Throws:
      IOException - If there is an error parsing the document.
    • processTextPosition

      protected void processTextPosition(TextPosition text)
      Description copied from class: PDFTextStripper
      This will process a TextPosition object and add the text to the list of characters on a page. It takes care of overlapping text.
      Overrides:
      processTextPosition in class PDFTextStripper
      Parameters:
      text - The text to process.
    • usage

      private static void usage()
      This will print the usage for this document.