What is the version of PHP than PDFNet SDK supports on Linux?

Q: We’ve recently downloaded PDFNet SDK for PHP, but are having problems getting it to run properly in our environment.

I wasn’t able to determine the specific system requirements from your documentation, but we’re running the following:

  • 64-bit CentOS Linux

  • PHP 5.2.17

  • Apache/2.2.3

After adding the “extension” line to the php.ini configuration file, I’m getting the following error:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/pdftron/PDFNetPHP.so’ -

/usr/lib64/php/modules/pdftron/PDFNetPHP.so: undefined symbol:

gc_remove_zval_from_buffer in Unknown on line 0

Is PDFNet SDK compatible with this version of PHP?

A: “PDFNet for PHP” is currently targeting PHP 5.3.6 or higher.

If you need to support older version of PHP you could use PDFNet for Java (or Python on C/C++) and then invoke a shell process from PHP.

PDFNet PHP README includes the following info that may be helpful to get started:


Table of Contents

  1. Linux setup
    Web Server
    Command Line

  2. Windows Setup
    Web Server
    Command Line

  3. Linux setup

The PHP sample codes can be executed in a web browser or the command line. Below explains the steps needed for both execution methods.

–Web server–

The following illustrates the steps for using the PDFNet PHP library with XAMPP. XAMPP is a simple to use Apache distribution which contains PHP. Note that this section can only be executed in the Linux 32 bit environment due to the limitations of XAMPP. Also note that the PDFNet library is not strictly limited to use with XAMPP only. It is compatible with other web servers as well.

  1. Download XAMPP 1.7.5 beta 1 or newer for Linux. The beta versions are available at the following link:
    http://www.apachefriends.org/en/xampp-beta.html
  2. Follow instruction at http://www.apachefriends.org/en/xampp-linux.html to install and start XAMPP on your Linux machine.
  3. After XAMPP is installed and started, open http://localhost in a web browser. Then, in the left panel, select “phpinfo()” under “Demos”. Record the path for php.ini next to “Loaded Configuration File”.
  4. Using the path for php.ini obtained in 3), add the following line to php.ini:
    extension=/pathToPDFNet/Lib/PDFNetPHP.so
    where pathToPDFNet is the directory of the PDFNetC folder

In addition, by default there should be a line for error reporting (“error_reporting = E_ALL | E_STRICT”). Remove E_STRICT from this line.

  1. Create a link to the “PDFNetC/Samples” folder in the htdocs folder within the XAMPP installation path. By default it should be /opt/lampp/htdocs. Rename the created link to “Samples”.

*A “Access Forbidden” error may result on certain Linux distributions. In this case, simply create a physical copy of the Samples and Lib folders and paste it in /opt/lampp/htdocs.
6) Restart XAMPP and then open a web browser, navigate to the location of the “Samples” folder at http://localhost/Samples.
7) A list of folders containing the samples should then be displayed. To run the samples, select the test folder of interest, then inside the “PHP” folder, click the php file to run. If the test contains printed contents, they should be displayed in the browser. If the test generates any files, they can be found in the Samples/TestFiles/Output folder
*Several tests may require special steps to run. Those instructions can be found within the test folder.

**Some Linux distribution may not be able to load the PDFNet library when running XAMPP with the following warning:

Warning: PHP Startup: Unable to load dynamic library ‘/opt/lampp/htdocs/Lib/PDFNetPHP.so’ - /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.0.0’ not found (required by /opt/lampp/htdocs/Lib/libPDFNetC.so) in Unknown on line 0

This can be fixed by replacing /opt/lampp/lib/libgcc_s.so.1 with /lib/libgcc_s.so.1/

***Some users may also receive errors of “Access to …/…/TestFiles/Output/___ was denied in /opt/lampp/htdocs/Lib/PDFNetPHP.php …”. This was due to the user not having the permission to write to the …/…/TestFiles/Output/ folder.

This can be fixed by changing the permission of the “Output” folder by right-clicking on the folder and selecting “Properties”. Then proceed to the “Permissions” tab to modify the user permission. The way to change permissions differs for each Linux distribution. On most distributions, an option should be available to change access to “Create and delete files”. If not, there should also be options for non-owners to “Write” to the folder.

–Command line–
The PDFNet PHP library can also be run from the command line. The advantage of running the samples in the command line is that users only need to perform step 4) from the above procedure. To locate php.ini, run the following php code:

<?php phpinfo(); ?>

The file directory should be displayed near the top of the output at the line of “Loaded Configuration File”.

The Samples folder contains a shell script which executes all the sample codes. In addition, each sample can be run individually by executing the shell script in each of the test folder. Note that the outputs of the sample codes are designed for web browsers. As a result, some HTML tags may be displayed in the console when running certain sample codes. This is the only difference between the outputs generated when running the samples in the command line compared to in a web server. This does not affect the functionality of the applicable sample codes.


  1. Windows Setup
    –Web server–
    The following illustrates the steps for using the PDFNet PHP library with XAMPP. XAMPP is a simple to use Apache distribution which contains PHP. Note that this section can only be executed in the Windows 32 bit environment due to the limitations of XAMPP. Also note that the PDFNet library is not strictly limited to use with XAMPP only. It is compatible with other web servers as well.
  1. Download XAMPP 1.7.5 beta 1 or newer for Windows. The beta versions are available at the following link:
    http://www.apachefriends.org/en/xampp-beta.html
  2. Follow instruction at http://www.apachefriends.org/en/xampp-windows.html to install and start XAMPP on your Windows machine.
  3. After XAMPP is installed and started, open http://localhost in a web browser. Then, in the left panel, select “phpinfo()” under the “PHP” section. Record the path for php.ini next to “Loaded Configuration File”.
    Default path should be C:\xampp\php\php.ini.
  4. Copy php_PDFNetPHPts.dll to xampp\php\ext and PDFNetC.dll to Windows\System32 folder.
    Also, Using the path for php.ini obtained in 3), add the following line to php.ini:
    extension=php_PDFNetPHPts.dll
    In addition, by default there should be a line for error reporting (“error_reporting = E_ALL | E_STRICT”). Remove E_STRICT from this line.
  5. Copy the PDFNet Samples and Lib folder to the xampp\htdocs folder
  6. Restart XAMPP and then open a web browser, navigate to the location of the “Samples” folder at http://localhost/Samples.
  7. A list of folders containing the samples should then be displayed. To run the samples, select the test folder of interest, then inside the “PHP” folder, click the php file to run. If the test contains printed contents, they should be displayed in the browser. If the test generates any files, they can be found in the Samples/TestFiles/Output folder

–Command line–

The PDFNet PHP library can also be run from the command line. The advantage of running the samples in the command line is that users only need to perform step 4) from the above procedure with some changes. Copy the php_PDFNetPHPts.dll and PDFNetC.dll to the ext folder in you PHP install directory instead. Also, to locate php.ini, type the following in the command line:

php --ini

The file directory is displayed at the line of “Loaded Configuration File”.

The Samples folder contains a batch script (runall_php.bat) which executes all the sample codes. In addition, each sample can be run individually by executing the batch script (RunTest.bat) in each of the test folder. Note that the outputs of the sample codes are designed for web browsers. As a result, some HTML tags may be displayed in the console when running certain sample codes. This is the only difference between the outputs generated when running the samples in the command line compared to in a web server. This does not affect the functionality of the applicable sample codes.