# Create 'download as PDF' option in web pages



## gdebojyoti (Nov 6, 2011)

I have often come across web pages which contain 'download-as-PDF' buttons (used to convert and download the data contained in that page in PDF format). How can I implement the same for my personal site?

P.S.: I don't want to use any web service for this. I prefer to do it from scratch.


----------



## coolpcguy (Nov 7, 2011)

I hope you're atleast willing to use some libraries - writing such a converter from scratch is painful

Writing my own HTML to PDF conversion library in PHP


----------



## thetechfreak (Nov 9, 2011)

Rather than messing around too much I would say download as HTML and convert to PDF using this
Download PrimoPDF 5.1.0.2 - FileHippo.com


----------



## d6bmg (Nov 9, 2011)

Use foxit reader and there will be an option to save any webpage as .pdf file (via print option)


----------



## coolpcguy (Nov 10, 2011)

thetechfreak said:


> Rather than messing around too much I would say download as HTML and convert to PDF using this
> Download PrimoPDF 5.1.0.2 - FileHippo.com





d6bmg said:


> Use foxit reader and there will be an option to save any webpage as .pdf file (via print option)



Umm - 



gdebojyoti said:


> I have often come across web pages which contain 'download-as-PDF' buttons (used to convert and download the data contained in that page in PDF format). How can I implement the same for my personal site?


----------



## Garbage (Nov 10, 2011)

See, we need some more information about your site.

1) Is it a CMS site? (Built using softwares like Wordpress, Drupal, Joomla, etc.). If yes, then you might be able to find an add-on / extension for this.

2) If it's a programmed web app, what is the language used? (PHP, Ruby, Python, Java, .Net, etc.)


----------



## Vyom (Nov 10, 2011)

thetechfreak said:


> Rather than messing around too much I would say download as HTML and convert to PDF using this
> Download PrimoPDF 5.1.0.2 - FileHippo.com





d6bmg said:


> Use foxit reader and there will be an option to save any webpage as .pdf file (via print option)



Quoted before you remove.


----------



## gdebojyoti (Nov 26, 2011)

Garbage said:


> See, we need some more information about your site.
> 
> 1) Is it a CMS site? (Built using softwares like Wordpress, Drupal, Joomla, etc.). If yes, then you might be able to find an add-on / extension for this.
> 
> 2) If it's a programmed web app, what is the language used? (PHP, Ruby, Python, Java, .Net, etc.)



No, I am not using any CMS. I am developing my website from scratch using PHP.

P.S.  Sorry for such a late reply. My internet connection was down for a couple of weeks.


----------



## Garbage (Nov 27, 2011)

This might help then:

dompdf - HTML to PDF converter (PHP5) - Google Project Hosting


> dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.



OR

HTML 2 PDF - a PHP script | Free software downloads at SourceForge.net


> Get a HTML text and generate a PDF file to make it printer-friendly. This PHP script is based upon FPDF PHP script (FPDF). More info can be found on the home page (HTML 2 (F)PDF Project).



Additionally, have a look at here as well - *stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php


----------



## Cool Buddy (Nov 29, 2011)

You will need to have a look at the FPDF library. This is a good place to look: Tutorials

However, I'd also suggest using Printfriendly. If you do it on your own, you will need to figure out how you would remove unnecessary content like ads from the PDF.


----------



## gdebojyoti (Nov 29, 2011)

Okay guys. Thanks a lot for your suggestions. I'll try them out ASAP.


----------

