Bootstrap Contact Form With Html To PDF Converter

This Bootstrap Contact Form With Html To PDF Converter is developed in Html, PHP and PDF extensions. This application is compose of Html forms to input a data of every persons or users. Every data that the user submitted it will directly sent to the pdf library and generate a print form. Each session of the submitted button creates from the Html it will convert automatically to a pdf format. This application will generally help to all the programmers for the converting and printing a file from the Html forms. See the example code below.

Sample Code

Index.html - This file we created is a simple contact form of data and shows that the submitted data is on a PDF format.
  1.         <title>Bootstrap Contact Form With Html To PDF Converter</title>
  2.         <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
  3.         <link href="css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
  4.         <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
  5.         <script type="text/javascript" src="js/bootstrap.min.js"></script>
  6. </head>
  7. <div class="container" align="center">
  8. <h2>Bootstrap Contact Form With Html To PDF Converter</h2>
  9.       <form class="contact-us form-horizontal" action="actionpdf.php" method="post">
  10.         <legend></legend>
  11.         <h3>Fill Up Form</h3>
  12.         <div class="control-group">
  13.             <label class="control-label">Name:</label>
  14.             <div class="controls">
  15.                 <div class="input-prepend" style="margin-left: -200px;">
  16.                 <span class="add-on"><i class="icon-user"></i></span>
  17.                     <input type="text" class="input-xlarge" name="name" placeholder="Name">
  18.                 </div>
  19.             </div>
  20.             <label class="control-label">Email:</label>
  21.             <div class="controls">
  22.                 <div class="input-prepend" style="margin-left: -200px;">
  23.                 <span class="add-on"><i class="icon-envelope"></i></span>
  24.                     <input type="text" class="input-xlarge" name="email" placeholder="Email">
  25.                 </div>
  26.             </div>
  27.             <label class="control-label">Url:</label>
  28.             <div class="controls">
  29.                 <div class="input-prepend" style="margin-left: -200px;">
  30.                 <span class="add-on"><i class="icon-globe"></i></span>
  31.                     <input type="text" id="url" class="input-xlarge" name="url" placeholder="http://www.example.com">
  32.                 </div>
  33.             </div>
  34.             <label class="control-label">Comment:</label>
  35.             <div class="controls">
  36.                 <div class="input-prepend" style="margin-left: -200px;">
  37.                 <span class="add-on"><i class="icon-pencil"></i></span>
  38.                     <textarea name="comment" class="span4" rows="4" cols="80" placeholder="Comment (Max 200 characters)"></textarea>
  39.                 </div>
  40.             </div>
  41.         </div>
  42.         <div class="control-group">
  43.           <div class="controls">
  44.             <button type="submit" class="btn btn-primary">Submit</button>
  45.             <button type="button" class="btn">Cancel</button>
  46.           </div>    
  47.         </div>
  48.       </form>
  49.         <div>
  50.                 <footer><a href="https://www.sourcecodester.com">Sourcecodester &copy 2016</a></footer>
  51.         </div>
  52. </div>
  53. </body>
  54. </html>
Actionpdf.php - This file contains PHP code to generate pdf file and show your submitted data on that file, and we also add page and auto page break true if your content increase single page area then it will automatically add a 2nd layer of page and process.
  1. <?php
  2. require('WriteHTML.php');
  3.  
  4. $pdf=new PDF_HTML();
  5. $pdf->AliasNbPages();
  6. $pdf->SetAutoPageBreak(true, 15);
  7. $pdf->AddPage();
  8. $pdf->Image('img/logo.jpg',20,15,25);
  9. $pdf->SetFont('Arial','B',14);
  10. $pdf->WriteHTML('<para><h1> Bootstrap Contact Form With Html To PDF Converter</h1><br>
  11. Website Address: <u>www.sourcecodester.com</u></para><br><br><br><br>Form Output<br/><br/>');
  12. $pdf->SetFont('Arial','B',7);
  13. $htmlTable='<TABLE>
  14. <TR>
  15. <TD>Name:</TD>
  16. <TD>'.$_POST['name'].'</TD>
  17. </TR>
  18. <TR>
  19. <TD>Email:</TD>
  20. <TD>'.$_POST['email'].'</TD>
  21. </TR>
  22. <TR>
  23. <TD>URl:</TD>
  24. <TD>'.$_POST['url'].'</TD>
  25. </TR>
  26. <TR>
  27. <TD>Comment:</TD>
  28. <TD>'.$_POST['comment'].'</TD>
  29. </TR>
  30. </TABLE>';
  31. $pdf->WriteHTML2("$htmlTable");
  32. $pdf->SetFont('Arial','B',6);
  33. $pdf->Output();
  34. ?>
result Hope that you learn in my tutorial. Don't forget to LIKE & SHARE this website. Enjoy Coding!

Comments

Thanks for sharing! I was in search in of this for a long time :)

Add new comment