Genrate html to pdf file using php
index.html
---------
---------
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Create Dynamic PDF using PHP and FPDF Library-Go2Code</title> <!-- CSS --> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="assets/css/form-elements.css"> <link rel="stylesheet" href="assets/css/style.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <!-- Favicon and touch icons --> <link rel="shortcut icon" href="assets/ico/favicon.png"> <link rel="apple-touch-icon-precomposed"
sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed"
sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72"
href="assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed"
href="assets/ico/apple-touch-icon-57-precomposed.png"> </head> <body> <!-- Top menu --> <nav class="navbar navbar-inverse navbar-no-bg" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button
" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#top-navbar-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> </div> </nav> <!-- Top content --> <div class="top-content"> <div class="inner-bg"> <div class="container"> <div class="row"> <div class="col-sm-4 text"> </div> <div class="col-sm-4 form-box"> <div class="form-bottom"> <form action="form.php" method="post" class="registration-form"> <button type="submit" class="btn" name="create">Create PDF</button> </form> </div> </div> </div> </div> </div> </div> <!--[if lt IE 10]> <script src="assets/js/placeholder.js"></script> <![endif]--> </body> </html>
form.php
-------
<?php
if(isset($_POST['create']))
{
$f_name="jaydep";
$l_name="Gondaliya";
$email="test";
$gender="male";
$date=date('d/m/Y');
require("fpdf/fpdf.php");
$fpdf=new FPDF();
$fpdf->AddPage();
$fpdf->setFont("Arial","B",16);
$fpdf->Cell(0,10,"AN AGREEMENT BETWEEN BUYER AND SELLER",1,1,"C");
$fpdf->SetFont('Arial','',14);
$fpdf->Write(10,'This Deed of Agreement is made and entered into on '.$date);
$fpdf->Ln('15');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('<p align="center">BETWEEN</p>');
$fpdf->Ln(1);
$fpdf->SetFont('Arial','',11);
$fpdf->MultiCell(0,8,'[Organisation jaydeep Gondaliya][An international non-government organisation
having its
Country Office at Rajkot represented by its Purchase Committee (here in after called
THE BUYER which term shall include
its successors and assigns) on the one Part.]',0,'L');
$fpdf->Ln('5');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('<p align="center">AND</p>');
$fpdf->Ln('5');
$fpdf->SetFont('Arial','',11);
$fpdf->WriteHTML('<pre>[jaydeep Gondaliya having its office at Rajkot (here in after called
THE SELLER which
term shall include successors and assigns) on the other Part.
Whereas Organisation krunal, has a Project to houses to Rajkot
And whereas for this purpose THE BUYER desires to appoint a SELLER to supply _____.
And whereas the SELLER expresses their desire to enter into an agreement with THE BUYER for
the job fully described in Schedule-A.
The ADDRESS shall be defined as Rajkot]</pre>');
$fpdf->Ln('7');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('Our Understanding :');
$fpdf->SetFont('Arial','',11);
$fpdf->WriteHTML(' We need to follow above format for agreement between buyer and seller.');
$fpdf->Ln('8');
$fpdf->SetFont('Arial','',11);
$fpdf->WriteHTML('1.That the Agreement shall come into force immediately and shall remain valid
until the final completion of the job or cancelled by the BUYER.<BR><BR>
2.That the materials more specifically described in Schedule-A shall be supplied by
the SELLER at ADDRESS. <BR><BR>
');
$fpdf->Ln('7');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('SCHEDULE - A');
$fpdf->Ln('8');
$header = array('Sl. No', 'Item', 'Specification', 'Warranty Duration','Quantity','Rate','Total');
// Data loading
$fpdf->SetFont('Arial','',11);
$data = $fpdf->LoadData('countries.txt');
$fpdf->BasicTable($header,$data);
$fpdf->Ln('7');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('Signed on the__________day of __________ for and on behalf
of the SELLER and BUYER as follows:');
$fpdf->Ln('9');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('SELLER BUYER<BR>');
$fpdf->SetFont('Arial','',11);
$fpdf->WriteHTML('1.....................................................................
1.............................................................................<BR>');
$fpdf->WriteHTML('2.....................................................................
2.............................................................................<BR>');
$fpdf->WriteHTML('3.....................................................................
3.............................................................................<BR>');
$fpdf->Ln('5');
$fpdf->SetFont('Arial','B',11);
$fpdf->WriteHTML('WITNESSES WITNESSES<BR>');
$fpdf->SetFont('Arial','',11);
$fpdf->WriteHTML('1.....................................................................
1.............................................................................<BR>');
$fpdf->WriteHTML('2.....................................................................
2.............................................................................<BR>');
$fpdf->WriteHTML('3.....................................................................
3.............................................................................<BR>');
$fpdf->output();
}
?>
countries.txt
-------------
1;Austria;Vienna;83859;8075
2;Belgium;Brussels;30518;10192
3;Denmark;Copenhagen;43094;5295
4;Finland;Helsinki;304529;5147
5;France;Paris;543965;58728
6;Germany;Berlin;357022;82057
7;Greece;Athens;131625;10511
8;Ireland;Dublin;70723;3694
9;Italy;Roma;301316;57563
10;Luxembourg;Luxembourg;2586;424
0 comments:
Post a Comment