title: Java - PDFBox - get text from PDF file
body: <p>I want to get raw text from a PDF file.<br />
  I am doing that :</p>
  <pre><code>public String parsePDF (String fileNameorFilePath){
      File f = new File(fileNameorFilePath);
      String parsedText;
      PDFParser parser = null;
      try {
          parser = new PDFParser(new RandomAccessFile(f, &quot;r&quot;));
          parser.parse();
          COSDocument cosDoc = parser.getDocument();
          PDFTextStripper pdfStripper = new PDFTextStripper();
          PDDocument pdDoc = new PDDocument(cosDoc);
          parsedText = pdfStripper.getText(pdDoc);
          if (cosDoc != null) cosDoc.close();
          return parsedText;
      } catch (IOException e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  <p>And I am getting this error :</p>
  <pre><code>java.io.IOException: Error : ~bfchar contains an unexpected operator : endcmap
  </code></pre>
  <p>at line</p>
  <pre><code>parsedText = pdfStripper.getText(pdDoc);
  </code></pre>
  <p>Is there a way to avoid this?</p>