Create 'download as PDF' option in web pages

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

Resistance is Futile.
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

Legend Never Ends
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

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

coolpcguy

Resistance is Futile.
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

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

Umm -

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

God of Mistakes...
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.)
 
OP
gdebojyoti

gdebojyoti

AFOL
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

God of Mistakes...
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

Wise Old Owl
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.
 
Top Bottom