Pages

Search This Blog

Friday 23 November 2012

HTML to PDF using PHP

Instructions HTML to PDF Using HTML2FPDF


    • 1
      Download the HTML2FPDF Class Library files (see Resources).
    • 2
      Paste the following code in Notepad:
      <?php
      require('html2fpdf.php');
      $pdf=new HTML2FPDF();
      $pdf->AddPage();
      $fp = fopen("yourfile.html","r");
      $strContent = fread($fp, filesize("sample.html"));
      fclose($fp);
      $pdf->WriteHTML($strContent);
      $pdf->Output("yourfile.pdf");
      echo "PDF file is generated successfully!";
      ?>
      Replace "yourfile.html" with the name of the HTML file you wish to convert and "yourfile.pdf" with your desired PDF file name.
    • 3
      Save it as a PHP file.
    • 4
      Upload your PHP file, the HTML2FPDF Class Library files, and the HTML file that you wish to convert in the same directory on your site.
    • 5
      Access the PHP file on your website to convert the HTML file to PDF.

    HTML to PDF Using DOMPDF

    • 6
      Download DOMPDF (see Resources).
    • 7
      Paste the following code in Notepad:
      <?php
      require_once("dompdf_config.inc.php");
      $html =
      '<html><body>'.
      '<p>Put your html here, or generate it with your favourite '.
      'templating system.</p>'.
      '</body></html>';
      $dompdf = new DOMPDF();
      $dompdf->load_html($html);
      $dompdf->render();
      $dompdf->stream("yourhtml.pdf");
      ?>
      In the section that indicates "Put your html here," paste the HTML code that you wish to convert to PDF.
    • 8
      Save it as a PHP file.
    • 9
      Upload your your PHP file and the DOMPDF files you downloaded within in the same directory on your site.
    • 10
      Access the PHP file on your website to convert HTML to PDF.

    Convert HTML to PDF Using PDFonFly

    • 11
      Go to pdfonfly.com.
    • 12
      Click on the "Text/HTML to PDF" link.
    • 13
      Click on "Source" in the text editing tool and paste your HTML.
    • 14
      Click on the "Create PDF" button.

Thursday 1 November 2012

Google Maps

<!--
Google Maps
Author: Zuh@ir Mirza
 -->
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySYM&sensor=false">
</script>

<script>
var myCenter=new google.maps.LatLng(51.508742,-0.120850);

function initialize()
{
var mapProp = {
  center:myCenter,
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker=new google.maps.Marker({
  position:myCenter,
  });

marker.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:600px;height:380px;"></div>
</body>
</html>