Hi, following url may help to you. http://articles.sitepoint.com/article/generate-pdfs-php just go through the above mentioned url there would be slightMessage 1 of 3 , Sep 30, 2010View SourceHi, following url may help to you.just go through the above mentioned urlthere would be slight change in code mentioned above url
// create handle for new PDF document
$pdf = pdf_new();
// open a file
// start a new page (A4)
pdf_begin_page($pdf, 595, 842);
// get and use a font object
$arial = pdf_findfont($pdf, "Arial", "host", 1); pdf_setfont($pdf, $arial, 10);
// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
// end page
// close and save file
your code will be changed at "print_text",
fetch data in html format from MySql using query,
$dbname="mydata"; //the name of the database
$chandle = mysql_connect("localhost", $dbuser, $dbpass)
or die("Connection Failure to Database");
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found. " . $dbuser);
$mainsection="links"; //The name of the table where web links are stored
$query1="select * from " . $mainsection . " as t1 where ((t1.active and t1.approved)
and (t1.cat1 = \"" . $section . "\" or t1.cat2 = \"" . $section . "\" or t1.cat3 = \"" . $section . "\"))
order by t1.score DESC, t1.hits DESC"; //select all approved links that belong to the current category
$result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1); //do the query
while ($i < mysql_num_fields($result))
pdf_show_xy($pdf, $thisrow[$i], 50, 750);
//echo $thisrow[$i] . " "; //Display all the fields on one line
echo <br>"; //put a break after each database entry
I hope your problem should be solved. If there exists still any problem let me know.----------
Air University Islamabad
From: shanto sas <saeedmail@...>
Sent: Fri, 1 October, 2010 0:54:24
Subject: Re: [phpXperts] HTML to PDF conversion
did you try dompdf? I think it will solved your problem. http://www.digitaljunkies.ca/dompdf/faq.php
group address for dompdf: <dompdf@...>
using dompdf you can do both. you can convert html to pdf by html page passing and data passing.
Jr. Software Engineer
Right Brain Solution LTD.
My Blog: http://saeed05.wordpress.com
--- On Thu, 30/9/10, Chaitanya <chaitanya.d@...> wrote:
From: Chaitanya <chaitanya.d@...>
Subject: [phpXperts] HTML to PDF conversion
Date: Thursday, 30 September, 2010, 8:51 PM
Hope you all are doing well.
Can you let me know how can I convert a html content into the pdf doc please?
When, googled on it, there are many packages, in which almost every example is showing that, we should pass a html file to the pdf library functions. My requirement is, instead of passing html page, the html data is stored in database, and should fetch it through a query and after that it should be exported to pdf.
Using a FCKEditor, data formatting is done and saving into the database. This data should be exported to pdf and formatting like bold, back ground colors should be applied as they are done with FCKEditor.
It would be great if you suggest me how to do it.
Thanks in advance,
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5492 (20100930) __________
The message was checked by ESET NOD32 Antivirus.