title: pdfbox extract word coordinates
body: <p>Hi This question refers to previous post:</p>
  
  <p><a href="https://stackoverflow.com/questions/50330484/could-someone-give-me-an-example-of-how-to-extract-coordinates-for-a-word-usin">Could someone give me an example of how to extract coordinates for a &#39;word&#39; using PDFBox</a></p>
  
  <p>I am using PDFBOX 2.0.10</p>
  
  <p>I have successfully compiled the combined code but getting exception error when trying to run an example.</p>
  
  <p>The solution provided does not have a standard main method which is where I am getting confused.</p>
  
  <p>Can someone please advise how I can run the combined code successfully.</p>
  
  <pre><code>package org.apache.pdfbox.examples.text;
  import java.io.File;
  import java.io.IOException;
  import java.io.ByteArrayOutputStream;
  import java.io.InputStream;
  import java.io.OutputStreamWriter;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.List;
  import org.apache.pdfbox.examples.text.ExtractWordCoordinates;
  public class ExtractWordCoordinates2 {
      public static void main(String[] args) throws IOException {
          ExtractWordCoordinates ewc = new ExtractWordCoordinates();
         ewc.testExtractWordsForGoodJuJu();
      }
  }
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>Jul 08, 2018 4:15:41 PM org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB suggestKCMS
  INFO: To get higher rendering speed on java 8 oder 9,
  Jul 08, 2018 4:15:41 PM org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB suggestKCMS
  INFO:   use the option -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider
  Jul 08, 2018 4:15:41 PM org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB suggestKCMS
  INFO:   or call System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider")
  Exception in thread "main" java.lang.NullPointerException
          at org.apache.pdfbox.io.ScratchFile.createBuffer(ScratchFile.java:422)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1142)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1041)
          at org.apache.pdfbox.examples.text.ExtractWordCoordinates.testExtractWordsForGoodJuJu(ExtractWordCoordinates.java:47)
          at org.apache.pdfbox.examples.text.ExtractWordCoordinates2.main(ExtractWordCoordinates2.java:17)
  </code></pre>
  
  <p>ExtractWordCoordinates can be found here
  <a href="https://github.com/mkl-public/testarea-pdfbox2/blob/master/src/test/java/mkl/testarea/pdfbox2/extract/ExtractWordCoordinates.java#L69" rel="nofollow noreferrer">https://github.com/mkl-public/testarea-pdfbox2/blob/master/src/test/java/mkl/testarea/pdfbox2/extract/ExtractWordCoordinates.java#L69</a></p>