title: Placing an image over text, by using the text postiton in a PDF using PDFBox.
body: <p>Result is that image is not placed correctly over text. Am i getting the text positions wrong?</p>
  
  <p>This is an example on how to get the x/y coordinates and size of each
  character in PDF</p>
  
  <pre><code>public class MyClass extends PDFTextStripper {
  
      pdocument = PDDocument.load(new File(fileName));
  
      stripper = new GetCharLocationAndSize();
      stripper.setSortByPosition(true);
      stripper.setStartPage(0);
      stripper.setEndPage(pdocument.getNumberOfPages());
      Writer dummy = new OutputStreamWriter(new 
      ByteArrayOutputStream());
      stripper.writeText(pdocument, dummy);
  
  
   /*
   * Override the default functionality of PDFTextStripper.writeString()
   */
  @Override
  protected void WriteString(String string, List&lt;TextPosition&gt; 
  textPositions) throws IOException {
  
       String imagePath = "image.jpg";
       PDImageXObject pdImage = 
       PDImageXObject.createFromFile(imagePath,pdocument);
  
       PDPageContentStream contentStream = new 
       PDPageContentStream(pdocument, stripper.getCurrentPage(), true, 
       true);
  
       for (TextPosition text : textPositions) {
  
           if (text.getUnicode().equals("a")) {
           contentStream.drawImage(pdImage, text.getXDirAdj(), 
           text.getYDirAdj(), text.getWidthDirAdj(),text.getHeightDir()); 
         }
         }
      contentStream.close();
      pdocument.save("newdoc.pdf");
      }
      }
  </code></pre>