View Full Version : Pdf format
name designation experience
-------- ----------- ------------
xxxx LEADER 4 years (for more information view,HTML,download pdf)
xxx DESIGNER fresher (for more information view,HTML,download pdf)
aaa MANAGER 10 years (for more information view,HTML,download pdf)
abcs PROGRAMMER 12 months(for more information view,HTML,download pdf)
now my problem is, name designation experience all these i can get it through database. but what i want is, code for downloading more information through pdf format or to view as html.PLEASE IF THERE IS ANY ONE WHO KNOW THIS PLEASE HELP ME:p:p:p
JShor
08-18-2009, 01:20 PM
Unfortunately,it's not as simple as one little snippet of code to do what you want.
First you'll need to have the library installed on your server [html2pdf].
http://sourceforge.net/projects/html2fpdf/files/
If you're running it on a hosted server that belongs to a host provider, ask them to install it for you. If they're cool,they'll do it.
From there, use this code:
<?php
$html= "<h1>hello</h1>"; //To add more html code use $html.= yourcode; in the next line
define('HTML2FPDF_VERSION','3.0(beta)');
define('RELATIVE_PATH','fpdf/');
define('FPDF_FONTPATH','font/');
require_once(RELATIVE_PATH.'fpdf.php');
require_once(RELATIVE_PATH.'htmltoolkit.php');
require_once(RELATIVE_PATH.'html2fpdf.php');
$pdf = new HTML2FPDF();
$pdf->WriteHTML($html);
$name="doc.pdf";
$pdf->Output($name);
?>
It's very self explanatory.$html is the html to convert to pdf format. Now, since you're using a database, you'll need to first create the html w/the data values, and THEN use the $html var to declare it.
When downloading the library, it'll give you a further explanation on how to do it. I don't think there's any online documentation for you to use.
HTH:)
now iam able to open pdf file but when i click on download option to save or open a alert box comes and it displays
__________________________________________________________________________
acrobat pdf can no t be open create.pdf because it is either not a supported file type or because the file has corrupted (for example it was sent as an email attachement and wasn't correctly decoded).
To create an Adobe PDF document, go to the source application,then print the document to adobe PDF
__________________________________________________________________________
my code is
echo"select * from registrationform where id=$_REQUEST[id]";
$gotten =mysql_query("select * from registrationform where id=$_REQUEST[id]");
$row = mysql_fetch_assoc($gotten);
$bytes = $row['event_picture'];
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=$bytes");
please help me
JShor
08-19-2009, 03:19 PM
OK, the file name must be a created file, it can't be a variable.
This is not correct, and will NOT work:
<?php
$bytes = $row['event_picture'];
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=$bytes");
?>
You will have to create a file, have it downloaded, and then optionally delete it when the download completes.
<?php
$file = "create.pdf";
$fh = fopen($file, 'w') or die("Cannot create file");
$bytes = $row['event_picture'];
fwrite($fh, $bytes);
fclose($fh);
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=$file");
?>
thnk u now i am getting it
JShor
09-05-2009, 10:32 PM
She needs to create it on the fly, using PHP.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.