Posted by & filed under HTML to PDF conversion, HTML to PDF SDK, PDF tooling.

Some time ago we wrote a post about how to convert an entire website to PDF by using our conversion service. In this post we’ll show you some sample code that you can use when you’re coding in PHP.

In PHP you can use our full-blown web to pdf sdk, which allows you to easily set your preferences, convert your pages and then merge them together into one large PDF. Before you start doing this, you should figure out a way to get all the pages of your website in a list. There are various tools on the web out there, some of which create an XML sitemap for example.

After you’ve decided which pages you want to convert you’ll basically put them in an array and then loop over these to convert them. As a last step you’ll then all merge them together.

Your code will then look something like this:

// initialize the service
$pdf = new Htm2PdfApi ($userid, $apikey');

// now set some options

// create an array with the URLs you want to convert
$urls = array (

// convert all these URLs one by one
foreach ($urls as $url) {
$pdf->CreateFromURL ($url);

// merge them all together and save them as one PDF!
$pdf->MergeFromCache (count($urls));

This should help you on your way! Of course if you don’t want to go through the trouble of doing this yourself, especially if you have a large website and you don’t know how to find all the pages – just contact us for a quote as we’ll be happy to do it for you!

Leave a Reply

You must be logged in to post a comment.