A package to extract text from a pdf original

by Freek Van der Herten – 1 minute read

For a project I needed to extract some text from a pdf. Although there were already a few packages that could to this, I still created spatie/pdf-to-text because I wanted something that was really easy to use. And also because it's fun creating packages.

Under the hood a utility called pdftotext is used. I provided some instructions in the readme on how to install that.

Here's an example of how to extract text from a pdf using the package:

Spatie\PdfToText\Pdf::getText('book.pdf');

And that's all there is to it, really.

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Found something interesting to share? Submit a link to the community section.