title: Extract headings, subheadings and paragraphs from PDF files using Python
body: <p>I want to extract the headings, subheadings and paragraphs from PDF files</p>
  <p>For example, my text is:</p>
  <pre class="lang-none prettyprint-override"><code>  1. Abstract 
  
      Some text 1
  
  
  
     2. Introduction 
  
      some text 2
  
     2.1. Background
  
         some text 2.1
  
    2.2. Reviews
  
         some text 2.2
  
    3. Methods
  
      some text 3
  
  
    4. References
  
      references
  </code></pre>
  <p>The <code>headings</code> list will be:</p>
  <blockquote>
  <ol>
  <li>Abstract, 2. Introduction, 2.1. Background, 2.2. Reviews, 3. Methods, 4. References)</li>
  </ol>
  </blockquote>
  <p>and the <code>paragraphs</code> list will be:</p>
  <blockquote>
  <p>some text 1, some text 2, some text 2.1, some text 2.2, some text 3, references</p>
  </blockquote>