Create PDF file of any URL

Now it is very easy to create a PDF file of any page or any reports etc.
Simply, you need to create the html page for which you need to create PDF.

For eg: If I want to create PDF of than I will simply put url of as shown in below example:

$url = "";
$file = phptopdf_url($url, 'pdf_examples/', "GOOGLE_HOMEPAGE.pdf");
// First Param : specifies the URL whose PDF to generate
// Second Param : specifies the storage location
// Third Param : defines the PDF filename 

I had created a function called "phptopdf_url()" to make it more clear
and structured. The function is follows: function phptopdf_url($source_url,$save_directory,$save_filename) { $API_KEY = 'd6s73mtjk85di7hm3'; $url = ''.$API_KEY.'&url='.urlencode($source_url); $resultsXml = file_get_contents(($url)); file_put_contents($save_directory.$save_filename,$resultsXml); return $save_directory.$save_filename; }

By executing above given code you can generate PDF. That’s it. 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s