Skip to content

Latest commit

 

History

History

PHP

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

PHP Sample Code

Details about using the Muhimbi PDF Converter Services from PHP can be found below. Further information, including the object model, can be found in the Developer Guide and in the Muhimbi Knowledge Base.

Any questions? Drop us a line, we love to help.


Table of Content


Prerequisites

The prerequisites to access the PDF Converter from PHP are as follows:

  • PHP
  • PHP SOAP libraries (See platform specific steps below)

Exact deployment and configuration steps for the various platforms vary slightly. The ones for Linux, tested with Ubuntu, and Windows are provided below.

❗ Please make sure that a copy of the Muhimbi PDF Converter Services (Download) is installed on at least one Windows Server in your environment. (Don't worry, it can be invoked from non-Windows platforms including Linux). :exclamation:


Linux

Deployment of the prerequisites is straight-forward. Feel free to adjust the steps if you need to deploy a different PHP version.

On Ubuntu 14.04

sudo apt-get install php5
sudo apt-get install php-soap

On Ubuntu 16.04

sudo apt-get install php7.0-cli
sudo apt-get install php7.0-soap

On Ubuntu 18.04

sudo apt-get install php7.2-cli
sudo apt-get install php7.2-soap

Using the instructions listed above will setup everything. On systems with an existing PHP deployment, check out this article if you run into any problems related to the SOAP libraries.


Windows

Please download and install the appropriate PHP version. We recommend installing it in c:\php. (Alternative PHP installation instructions by Microsoft)

The PHP Soap libraries are enabled in the Windows PHP distribution and don't need to be installed separately. To troubleshoot SOAP related issues see this article.


Configure PHP (same for all platforms)

When dealing with document conversions and merge operations, the default php.ini values for upload_max_filesize and post_max_size may be too conservative and should be increased to a value that matches your requirements.

This can be achieved by updating, or adding, the following values in your php.ini (these values are already set to 50MB in the php.ini files that ship with our sample code):

upload_max_filesize = 50M
post_max_size = 50M

If you expect to execute long running operations (e.g. long OCR operations or complex file merges) then you may want to read-up on dealing with PHP socket timeouts:


Download Sample Code

Sample code, and related files, for the various facilities provided by the service can be found below. It is recommended to copy all samples to your local system using one of the following options:

  • Git: Use the following command to clone the entire repository to your system. This will download all files associated with this repository, and is most likely overkill, but it is the only easy way to download files using Git. Once downloaded, you can find the example under the PHP folder.

    git clone https://github.com/Muhimbi/PDF-Converter-Services/

  • 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/trunk/PHP

  • ZIP: Download a ZIP archive of the entire repository. Once downloaded, you can find the examples under the PHP folder.


A full overview of the examples can be found below.

Sample Description
Convert Convert a single file to PDF or other supported output format. As part of this sample a watermark is applied to the PDF as well.

Any questions? Drop our friendly support desk a line, we love to help.