Class DrawPrintTextLocations


public class DrawPrintTextLocations extends PDFTextStripper
This is an example on how to get some x/y coordinates of text and to show them in a rendered image.
  • Field Details

  • Constructor Details

    • DrawPrintTextLocations

      public DrawPrintTextLocations(PDDocument document, String filename) throws IOException
      Instantiate a new PDFTextStripper object.
      Parameters:
      document -
      filename -
      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.
    • showGlyph

      protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement) throws IOException
      Description copied from class: LegacyPDFStreamEngine
      Called when a glyph is to be processed. The heuristic calculations here were originally written by Ben Litchfield for PDFStreamEngine.
      Overrides:
      showGlyph in class LegacyPDFStreamEngine
      Parameters:
      textRenderingMatrix - the current text rendering matrix, Trm
      font - the current font
      code - internal PDF character code for the glyph
      displacement - the displacement (i.e. advance) of the glyph in text space
      Throws:
      IOException - if the glyph cannot be processed
    • calculateGlyphBounds

      private Shape calculateGlyphBounds(Matrix textRenderingMatrix, PDFont font, int code) throws IOException
      Throws:
      IOException
    • stripPage

      private void stripPage(int page) throws IOException
      Throws:
      IOException
    • writeString

      protected void writeString(String string, List<TextPosition> textPositions) throws IOException
      Override the default functionality of PDFTextStripper.
      Overrides:
      writeString in class PDFTextStripper
      Parameters:
      string - The text to write to the stream.
      textPositions - The TextPositions belonging to the text.
      Throws:
      IOException - If there is an error when writing the text.
    • usage

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