title: Paragraph extraction in PyMuPDF
body: <p>I'm using PyMuPDF to extract text from PDFs from block units. In many cases, &quot;blocks&quot; seem to just default to newline separated units, rather than logical paragraphs.</p>
  <pre><code>import fitz
  doc = fitz.open(&quot;example.pdf&quot;)
  blocks = [x[4] for x in  doc[0].getText(&quot;blocks&quot;)]
  print(blocks)
  </code></pre>
  <p>(example.pdf can be found <a href="https://textgain.com/scratch/example.pdf" rel="nofollow noreferrer">here</a>)</p>
  <p>I could live with this, were it not for the fact that straight copy/pasting from Mac's bog standard Preview app, beautifully retains the paragraphs. What is Preview doing that PyMuPDF isn't? The rest of my pipeline is pretty much locked into PyMuPDF, so I can't really use Preview for extraction.</p>