projects > pdfb library - barcodes in dynamic pdfs

PDFB Library - Barcodes in Dynamic PDFs

Live Demo of PDFB Library

  1. Let us take this base PDF as a template.
  2. Now write this simple PHP code.
  3. Voila! Generate the PDF on the fly!
  4. View the ReadMe.txt file for more info.

Download PDFB Library

Credits

License

Usage

  1. Download PDFB Library from the links above.
  2. Extract to any folder on your server that is accessible by a web browser.
  3. Go to demo.php on your server to test it. If you see a PDF, then success! Rejoice!
  4. Otherwise spend all night trying to figure out what's wrong.
  5. Before you give up, make sure you have PHP Image library setup correctly.

Sample Code

<?php

  
require("pdfb/pdfb.php"); // Must include this

  
class PDF extends PDFB
  
{
    function 
Header()
    {
      
// Add your code here to generate
      // Headers on every page
    
}

    function 
Footer()
    {
      
// Add your code here to generate
      // Footers on every page
    
}
  }

  
// Create a PDF Page object
  
$pdf = new PDF("p""pt""letter");

  
// Load the base PDF into template
  
$pdf->setSourceFile("demo.pdf");
  
$tplidx $pdf->ImportPage(1);

  
// Add new page & use the base PDF as template
  
$pdf->AddPage();
  
$pdf->useTemplate($tplidx);

  
// See pdfb/pdfb.php for parameters on BarCode()
  // Create a Code 128-B barcode
  
$pdf->BarCode("PKG1234""C128B");

  
// UPC-A Barcode
  
$pdf->BarCode("73725735882""UPCA"300300);

  
$pdf->Output();
  
$pdf->closeParsers();

?>

Documentation

Disclaimer