Get started :: PHP to PDF generation steps

  1. Sign up to access our API    
    FREE!
  2. Download and include phpToPDF.php
  3. Call functions to generate PDFs

 

Sample Code :: PHP to PDF Generaton [ More Examples ]

Use the phptopdf() function for creating a PDF using a URL

<?php
    
require('phpToPDF.php');

    
//Set Your Options -- see documentation for all options
    
$pdf_options = array(
          
"source_type" => 'url',
          
"source" => 'http://google.com',
          
"action" => 'save');

    
//Code to generate PDF file from options above
    
phptopdf($pdf_options);
?>

Alternatively, you can use the phptopdf() function to pass a varible that holds html code for your PDF.

<?php
    
require('phpToPDF.php');

    
//Your HTML in a variable
    
$my_html="<HTML><h2>PDF from HTML using phpToPDF</h2></HTML>";

    
//Set Your Options -- we are saving the PDF as 'my_filename.pdf' to a 'my_pdfs' folder
    
$pdf_options = array(
      
"source_type" => 'html',
      
"source" => $my_html,
      
"action" => 'save',
      
"save_directory" => 'my_pdfs',
      
"file_name" => 'my_filename.pdf');

    
//Code to generate PDF file from options above
    
phptopdf($pdf_options);
?>

No Installation Needed

No packages or command line access needed. No heavy resources required. We do the heavy lifting.

Works on ANY server running PHP

The simplest and most reliable PHP to PDF generation.
Just include a single php file.