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:
    [B][COLOR="#FF0000"]You require 'pdfcrowd.php';[/COLOR][/B]
    
    [COLOR="#008000"]// create an API client instance[/COLOR]
    $client = new Pdfcrowd("username", "apikey");
    
    [COLOR="#008000"]// convert a web page and store the generated PDF into a variable[/COLOR]
    $pdf = $client->convertURI('http://www.google.com/');
    
    [COLOR="#008000"]// set HTTP response headers[/COLOR]
    header("Content-Type: application/pdf");
    header("Cache-Control: max-age=0");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"google_com.pdf\"");
    
    [COLOR="#008000"]// send the generated PDF[/COLOR]
    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