title: Extract bold words from pdf
body: <p>I am trying to export the bold words into caps of a pdf file to a text file using pdfbox library. I want to live one blank line after the word in bold. As you can see from the pdf file(<a href="http://www.museduc.gr/docs/gymnasio/Dictionary.pdf" rel="nofollow noreferrer">Dictionary.pdf</a>) starting from page 15 its a dictionary with the definitions. The words are in bold and the definitions have normal font. </p>
  
  <p>Here is how i want to my text file to look like:<br>
  "Dictionary Source:<br>
  ΑΒΑθΗΣ<br>
  ΑΒΑθΗΣ<br>
  ΑΒΑθΕΣ<br>
  ΕΠΙΘ.: όταν κάτι είναι αβαθές, δεν έχει μεγάλο βάθος (=
  ρηχός, άβαθος ≠ βαθύς): Τα παιδιά μαθαίνουν
  κολύμπι στα αβαθή νερά.
  ...."</p>
  
  <p>Here is my code but unfortunately it can't separate bold from normal font. After debugging the code i realised that even if there is a bold character the text.getFont().getFontDescriptor().isForceBold() is false and text.getFont().getFontDescriptor().getFontWeight()=0 .</p>
  
  <pre><code>public class PDFBoldParser extends PDFTextStripper {
  
      PrintWriter writer;
      boolean wasBold=false;
  
      public PDFBoldParser(String filepath) throws IOException{
          writer=new PrintWriter(filepath,"UTF-8");
          writer.println("Dictionary Source:");
      }
  
      @Override
      protected void processTextPosition(TextPosition text){
          if(text.getFont().getFontDescriptor()!=null){
              if (text.getFont().getFontDescriptor().isForceBold() ||
                      text.getFont().getFontDescriptor().getFontWeight() &gt; 680 &amp;&amp;wasBold) {
                  writer.print(text.toString().toUpperCase());
                  wasBold=true;
              }
              else if(text.getFont().getFontDescriptor().isForceBold() ||
                      text.getFont().getFontDescriptor().getFontWeight() &gt; 680 &amp;&amp;!wasBold){
                  writer.println();
                  writer.print(text.toString().toUpperCase());
                  wasBold=true;
              }
              else{
                  writer.print(text.toString());
                  wasBold=false;
              }
          }
      }
  
      public void closeParser(){
          writer.close();
      }
  }
  </code></pre>