Announcement

Collapse
No announcement yet.

How to convert HTML form to a PDF page by using PHP?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to convert HTML form to a PDF page by using PHP?

    Hi,
    Is it possible to convert my website from HTML form to a PDF page and it will be saved on the server after submitting?

  • #2
    Hello,
    Use the following code converts a web page to generated PDF as an HTTP response:

    Code:
    You require 'pdfcrowd.php';
    
    // create an API client instance
    $client = new Pdfcrowd("username", "apikey");
    
    // convert a web page and store the generated PDF into a variable
    $pdf = $client->convertURI('http://www.google.com/');
    
    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: max-age=0");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"google_com.pdf\"");
    
    // send the generated PDF
    echo $pdf;
    I hope it works out for you as well.

    Comment


    • #3
      If you want to convert your html website to pdf then you may use the following code

      Code:
      require('fpdf.php');
      
      $pdf = new FPDF();
      
      $pdf->AddFont('georgia', '', 'georgia.php');
      $pdf->AddFont('georgia', 'B', 'georgiab.php');
      $pdf->AddFont('georgia', 'I', 'georgiai.php');
      
      # Add UTF-8 support (only add a Unicode font)
      $pdf->AddFont('freesans', '', 'freesans.php', true);
      $pdf->SetFont('freesans', '', 12);
      
      $pdf->SetTitle('My title');
      $pdf->SetAuthor('My author');
      $pdf->SetDisplayMode('fullpage', 'single');
      
      $pdf->SetLeftMargin(20);
      $pdf->SetRightMargin(20);
      
      $pdf->AddPage();
      $pdf->Cell(40,10,'Hello World!');
      $pdf->Output();

      Comment


      • #4
        Change over HTML to PDF utilizing PHP fast and simple utilizing magnificent

        Comment

        Working...
        X