Do you own a Debenu Quick PDF Library 10/9/8/7? Upgrade to Debenu Quick PDF Library 11!

Debenu Quick PDF Library

PDF Web Apps, With Quick PDF Library and PHP

May 6, 2009

Customers often ask: does Quick PDF Library work with PHP? The answer is yes, and what’s more, it works very well with minimal setup required.

What does this mean? It means that you can use Quick PDF with PHP to build PDF web apps that do things like split and merging PDFs, modify security, etc, but also, it means you can add PDF functionality to your existing online apps. Do you want to generate PDF reports from a database on the fly and serve them up to customers through your website? No problem, Quick PDF Library can do that and much more. 

In this example I will show you how to use Quick PDF and PHP with a few simple steps. To demo the library I will be using the ActiveX version of Quick PDF Library and the version of PHP5 and Apache that is bundled with XAMPP. Of course, Quick PDF will also work with PHP and IIS, but I’ll leave that example for another day.

Steps to follow

  1. Install XAMPP for Windows (alternatively you could install PHP and Apache separately if you wished).
  2. Create a folder for your PHP project in c:\xampp\htdocs.
  3. Download and install Quick PDF Library to a directory on your machine.
  4. Locate the ActiveX edition (QuickPDFAX0713.dll) of Quick PDF Library and register it (regsvr32 <path>\QuickPDFAX0713.dll).
  5. Create a PHP file and add it to your project in the htdocs folder (e.g. c:\xampp\htdocs\qpl\index.php).
  6. Open the PHP file and add the following code and then save it.
  7. <?php
    $fileName = “DrawText.pdf”;
    $qp = new COM(“QuickPDFAX0713.PDFLibrary”);
    $validKey = $qp->UnlockKey(“…”);
    if ($validKey == 1)
    {
        echo “License validation successful!”;
        echo “<br />”;
        echo “Valid license key: “;
        echo $qp->LicenseInfo;
        echo “<br />”;
    }
    else
    {
        echo “License validation failed!”;
        echo “<br /><br />”;
    }
    $qp->DrawText(100, 500, “Hello World!”);
    $result = $qp->SaveToFile($fileName);
    if ($result == 1)
    {
        echo “File was successfully saved to disk.”;
        echo “<br /><br />”;
    }
    else
    {
        echo “File could not be saved to disk.”;
        echo “<br /><br />”;
    }
    $qp = null;
    ?>

  8. Execute the PHP file by loading it in your browser (e.g. http://localhost/qpl/index.php) and you’re done!

Some tips

// $qp = new COM(“QuickPDFAX0713.PDFLibrary”);

Call the Quick PDF Library COM object that you have previously registered. It shouldn’t matter where the QuickPDFAX0713.dll file is physically located, however, keeping it in the project folder will ensure that you don’t accidentally delete it. 

// $result = $qp->SaveToFile($fileName);

By default, when saving files to disk using the Apache service that accompanies XAMPP, the files that are created in this example will automatically be placed in the following directory: c:\xampp. Of course, it’s relatively easy to save the file in a different location with a small few adjustments to the PHP code, but I’ll leave that work for you.

The rest of this code should be quite easy to understand. But if you have any questions, leave a comment.

The example that I’ve used in this sample is quite simple, however, there’s no reason why it couldn’t be far more sophisticated. After all, with over 500 functions in the Quick PDF Library, you could build some pretty powerful PDF web apps.

2 Comments »

  1. Any chance for a little guidance on IIS Install, for use to merge two .pdf via PHP?
    Doesn’t hurt to ask!
    Thx.

    Comment by Rob D — June 6, 2011 @ 6:06 pm

  2. Hi Rob, any particular reason that you want to use IIS for this? You could use something like XAMPP if you want to use PHP on Windows. That is what we have done all of our PHP and Quick PDF Library testing with. But if you want to use PHP on IIS then Quick PDF Library should work with that successfully too. There are some instructions on the page below for how to install PHP on IIS:

    http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx

    Comment by Rowan — June 7, 2011 @ 3:15 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>




© 2014 Debenu. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum