How to Split PDF by Text in PHP using PDF.co Web API
In this tutorial, we will show you how to Split PDF by Text in PHP using PDF.co Web API. Below is the image of the PDF input with three pages and the split PDF files output.
Contents
Source Code
First, let’s copy the HTML and the PHP source code.
Let’s save the files inside a folder in the www directory.
Start Apache
Next, open the files in your favorite editor and start the Apache server.
Run Program
Now, let’s run the program.
- In your browser type in
localhost/folder_name/sample.html
and hit Enter. - Then, add your PDF.co API Key. You can get it in your PDF.co dashboard.
- Load the sample PDF file. Go here to get a copy of the sample PDF Invoice.
- In the Split Search Text field, let’s leave the default string invoice number. Every time the engine encounters the word invoice number it will split the page from the rest of the document.
Click Proceed.
Output
The sample PDF Invoice has three pages. Each page contains the word invoice number. The PDF Splitter Web API generated three URLs for each page.
In this tutorial, you learned how to split PDF by text in PHP using PDF.co Web API. You also learned how to run the program using an Apache Server.