FishSword Posted December 29, 2010 Share Posted December 29, 2010 Hiya! I need to create a simple PDF script that will always create A4 documents. I need the content to be controlled using HTML and CSS. Where do you start in creating such a script? Any help is greatly received. Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/ Share on other sites More sharing options...
BlueSkyIS Posted December 29, 2010 Share Posted December 29, 2010 HTML and CSS do not easily convert to page layout, if they can be converted at all. you can use some HTML-ish styling with FPDF, http://fpdf.org/ I haven't tried this, but it's listed on the scripts page at fpdf.org: http://html2fpdf.sourceforge.net/ Good Luck! Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/#findComment-1152579 Share on other sites More sharing options...
FishSword Posted December 29, 2010 Author Share Posted December 29, 2010 Thanks for your reply. I'm trying to make a script similar to FPDF, but much simpler. All I want to do is create an A4 document, then alter the page(s) using HTML and CSS. Do you know where I would need to start in making such a script? How do I create a new pdf document, and insert HTML and CSS without using a ready made solution? I'm against using a ready-made solution as it will make my original script more bloated. Any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/#findComment-1152600 Share on other sites More sharing options...
BlueSkyIS Posted December 29, 2010 Share Posted December 29, 2010 The problem is that PDFs don't automatically use or interpret HTML or CSS. If you want to use HTML- and CSS-like tags in a PDF, you have 2 options: 1. use a ready made solution that sort of does the job, or 2. create a new solution. If you want to get an idea of what it would take to create a new solution, I suggest that you download the source code for FPDF and take a look. And that's just a script to create a PDF, no HTML or CSS included. Is there a reason that you need to use HTML and CSS in the PDF? If not, you can do anything that you can do with HTML and CSS (and more), but without the use of HTML and CSS tags. Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/#findComment-1152624 Share on other sites More sharing options...
FishSword Posted December 29, 2010 Author Share Posted December 29, 2010 Once again, thanks for your help So does HTML and CSS just complicate things? Would it be easier to do it through other means? - If so how and what? Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/#findComment-1152630 Share on other sites More sharing options...
BlueSkyIS Posted December 29, 2010 Share Posted December 29, 2010 Using FPDF, you can do anything in a PDF that HTML/CSS can do on a web page: change fonts, colors, sizes, draw tables, place/resize images, create links within the PDF or to external websites, etc., etc., etc. You just need to learn how to use FPDF. There are tutorials and sample scripts on the website. One of the scripts that you can download allows some HTML tags, but I found it to produce unreliable results. Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/#findComment-1152632 Share on other sites More sharing options...
FishSword Posted December 29, 2010 Author Share Posted December 29, 2010 Does FPDF, and other PDF classes use GD to add text to the document? I can't figure out how this is done. Quote Link to comment https://forums.phpfreaks.com/topic/222902-simple-html-css-to-pdf-script/#findComment-1152657 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.