Jump to content

How do I convert a webpage into a PDF file using PHP?


justineaguas

Recommended Posts

I want to convert a webpage from my system using PHP into a PDF file. Just how http://www.web2pdfconvert.com/ works. However, I want to have a link that says 'Convert to PDF' then it automatically converts the webpage into a PDF. Is there any way to do this?

If you click the "Browser Tools" you can see they've given you a button you can drag into your bookmarks and hovering over that button you can see the following in the status bar of your browser:

javascript:void(window.open('http://www.web2pdfconvert.com/convert.aspx?cURL='+escape(location.href)+'&title='+escape(document.title)+'&ref=browser'+''))

 

Here we can see you can pass the link of a website as "cURL" and the page title as "title" so a link might look something like:

http://www.web2pdfconvert.com/convert.aspx?cURL=http://www.phpfreaks.com&title=PHP Freaks

 

EDIT: Forgot to mention, always escape the URL and title strings before passing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.