SlideShare a Scribd company logo
PHP and PDFlib

South Florida PHP Users Group


                   Adam Culp
                 http://www.Geekyboy.com



In this session we will cover some basics of using
  PDFlib with PHP.          We will install the
  application, cover where to find more info and
  resources, and basic usage.
PHP and PDFlib

The Source
  Http://www.pdflib.com/
Installation

Installation is as easy as 1-2-3
  Copy the application to modules directory
     /usr/lib/php5/20090626+lfs

  Add module to php.ini (extension=libpdf_php.so)
  Restart Apache
  Use PDFLib
Free VS Commercial

PDFlib has a lite version as well as Commercial
  Lite is free, but limited functionally
  Lite is not pre-compiled
  Commercial is fully functional (for $1.1K, or $2.2K)
  Commercial can be used fully, but has watermark
   until licensed.
Capabilities

Too many capabilities to cover here...
  Merge multiple PDF files
  Fill in form on PDF and save
  Create complex document layout
  Populate pre-built blocks in PDF
Basics

To use PDFlib in PHP you simply:
  Instantiate PDFlib
  Customize your object
  Output two ways
     Dump to screen from buffer as download
        header("Content-type: application/pdf");
        header("Content-Length: $len");
        header("Content-Disposition: inline; filename=businesscard.pdf");
     Save to hard drive with file_put_contents
Structure

Necessary code elements:
      $p = new PDFlib();
      $p->begin_document($outfilename, "openmode=none");
      $p->begin_page_ext(10, 10, "");
      // add stuff here using methods
      $p->end_page_ext("");
      $p->end_document("");
      $buf = $p->get_buffer();
      $len = strlen($buf);

      // output to browser as download
      header("Content-type: application/pdf");
      header("Content-Length: $len");
      header("Content-Disposition: inline; filename=hello.pdf");
      print $buf;

      // or save to disk
      file_put_contents($searchpath . '/' . $filename, $buf);

More Related Content

ODP
Php File Upload
PDF
Introduction to Web Designing
PDF
Php tutorial from_beginner_to_master
PPTX
Uploading a file with php
PDF
Data cache management in php
PPT
File Upload
ODP
Coding In Php
Php File Upload
Introduction to Web Designing
Php tutorial from_beginner_to_master
Uploading a file with php
Data cache management in php
File Upload
Coding In Php

What's hot (19)

PPTX
PHP presentation - Com 585
PPTX
PHP in one presentation
PPT
Local Drupal MultiSite Set-up
PPTX
PPTX
File Uploading in PHP
PPTX
PHP Hypertext Preprocessor
PDF
PHP Includes
PPTX
Presentation php
ODP
Drupal Themes
PPT
05 File Handling Upload Mysql
PPTX
Web server scripting - Using a form
ODP
PHP BASIC PRESENTATION
PDF
Resourcesforweb
 
PPTX
Php file upload, cookies & session
PPTX
PDF
Php workshop L04 database
PPTX
Php presentation
PHP presentation - Com 585
PHP in one presentation
Local Drupal MultiSite Set-up
File Uploading in PHP
PHP Hypertext Preprocessor
PHP Includes
Presentation php
Drupal Themes
05 File Handling Upload Mysql
Web server scripting - Using a form
PHP BASIC PRESENTATION
Resourcesforweb
 
Php file upload, cookies & session
Php workshop L04 database
Php presentation
Ad

Similar to PHP and PDFLib (15)

PPT
The FPDF Library
PPT
Introduction to FPDF - DC PHP
PPT
Introduction to FPDF
PDF
Adobe AIR & Printing
PDF
Introduction into PHP5 (Jeroen van Sluijs)
PDF
PPT
PHP and COM
PPTX
Flex and PHP For the Flash Folks
PPT
Zend framework 06 - zend config, pdf, i18n, l10n, sessions
PDF
Integrating PHP With System-i using Web Services
PPTX
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
PDF
Profiling PHP with Xdebug / Webgrind
PDF
Professional PHP: an open-source alternative for enterprise development [Kort...
The FPDF Library
Introduction to FPDF - DC PHP
Introduction to FPDF
Adobe AIR & Printing
Introduction into PHP5 (Jeroen van Sluijs)
PHP and COM
Flex and PHP For the Flash Folks
Zend framework 06 - zend config, pdf, i18n, l10n, sessions
Integrating PHP With System-i using Web Services
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
Profiling PHP with Xdebug / Webgrind
Professional PHP: an open-source alternative for enterprise development [Kort...
Ad

More from Adam Culp (20)

PDF
Hypermedia
PDF
Putting legacy to REST with middleware
PDF
php-1701-a
PDF
Release your refactoring superpower
PDF
Managing Technical Debt
PDF
Developing PHP Applications Faster
PDF
Containing Quality
PDF
Debugging elephpants
PDF
Zend expressive workshop
PDF
Expressive Microservice Framework Blastoff
PDF
Foundations of Zend Framework
PDF
Accidental professional
PDF
Build great products
PDF
Does Your Code Measure Up?
PDF
Practical PHP Deployment with Jenkins
PDF
Virtualizing Development
PDF
Refactoring Legacy Code
PDF
Deprecated: Foundations of Zend Framework 2
PDF
Clean application development tutorial
PDF
Refactoring 101
Hypermedia
Putting legacy to REST with middleware
php-1701-a
Release your refactoring superpower
Managing Technical Debt
Developing PHP Applications Faster
Containing Quality
Debugging elephpants
Zend expressive workshop
Expressive Microservice Framework Blastoff
Foundations of Zend Framework
Accidental professional
Build great products
Does Your Code Measure Up?
Practical PHP Deployment with Jenkins
Virtualizing Development
Refactoring Legacy Code
Deprecated: Foundations of Zend Framework 2
Clean application development tutorial
Refactoring 101

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Tartificialntelligence_presentation.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
August Patch Tuesday
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Mushroom cultivation and it's methods.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Tartificialntelligence_presentation.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
OMC Textile Division Presentation 2021.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectroscopy.pptx food analysis technology
Machine Learning_overview_presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
August Patch Tuesday
cloud_computing_Infrastucture_as_cloud_p
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Mushroom cultivation and it's methods.pdf
1. Introduction to Computer Programming.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Accuracy of neural networks in brain wave diagnosis of schizophrenia
NewMind AI Weekly Chronicles - August'25-Week II
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence

PHP and PDFLib

  • 1. PHP and PDFlib South Florida PHP Users Group Adam Culp http://www.Geekyboy.com In this session we will cover some basics of using PDFlib with PHP. We will install the application, cover where to find more info and resources, and basic usage.
  • 2. PHP and PDFlib The Source Http://www.pdflib.com/
  • 3. Installation Installation is as easy as 1-2-3 Copy the application to modules directory /usr/lib/php5/20090626+lfs Add module to php.ini (extension=libpdf_php.so) Restart Apache Use PDFLib
  • 4. Free VS Commercial PDFlib has a lite version as well as Commercial Lite is free, but limited functionally Lite is not pre-compiled Commercial is fully functional (for $1.1K, or $2.2K) Commercial can be used fully, but has watermark until licensed.
  • 5. Capabilities Too many capabilities to cover here... Merge multiple PDF files Fill in form on PDF and save Create complex document layout Populate pre-built blocks in PDF
  • 6. Basics To use PDFlib in PHP you simply: Instantiate PDFlib Customize your object Output two ways Dump to screen from buffer as download header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=businesscard.pdf"); Save to hard drive with file_put_contents
  • 7. Structure Necessary code elements: $p = new PDFlib(); $p->begin_document($outfilename, "openmode=none"); $p->begin_page_ext(10, 10, ""); // add stuff here using methods $p->end_page_ext(""); $p->end_document(""); $buf = $p->get_buffer(); $len = strlen($buf); // output to browser as download header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $buf; // or save to disk file_put_contents($searchpath . '/' . $filename, $buf);