The PHP sample provided in this section uses the Muhimbi PDF Converter Services Online to split up a single PDF into multiple smaller ones. Additional sample code to convert, merge, watermark, secure and OCR files can be found here.
Full details about the split_pdf
method, fields and properties can be found in the Wiki.
Download the sample code using a method of your choice. Some examples are provided below.
-
Git: Clone the entire repository to your system. You can find the examples under the
clients/v1/php/samples
folder.git clone https://github.com/Muhimbi/PDF-Converter-Services-Online
-
SVN: A common trick to download only part of a Git repository is to use
svn
. Download only the PHP client and sample code using the following command.svn export https://github.com/Muhimbi/PDF-Converter-Services-Online/trunk/clients/v1/php
-
ZIP: Download a ZIP archive of the entire repository. Once downloaded, you can find the examples under the
clients/v1/php/samples
folder.
In order to successfully execute the sample code, make sure you have a valid subscription, either a full one or the 30 day trial.
❗ Each subscription comes with a unique api_key
. Before executing the sample, please insert your key in the code. ❗
Make sure the prerequisites are in place. The sample code expects the client libraries to be present under ../../client/
.
There are many ways to execute PHP code, in this example we use PHP's internal web server, but naturally it will work equally well using Apache, IIS or any other PHP capable platform.
Launch PHP and activate the built-in web server as follows:
php -S localhost:8080 -t some_path_to/PDF-Converter-Services-Online/clients/v1/php/samples/split_pdf
You may want to change the port number and naturally you must specify the full path to the folder containing this sample.
With PHP running - and in this example - listening on port 8080, open a browser and navigate to http://localhost:8080/split_pdf.php
.
Choose an existing PDF file and click the Split
button. The specified file will be split up in chunks of 2 pages (or whatever you configure in the code). As we can return only a single file to the browser, in this demo we return the 2nd file (pages 3 and 4) if it exists, otherwise the first file (in case the source PDF is only 1 or 2 pages).
If you have any questions or comments then please contact our friendly support desk.