WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Generate FDF files without the pdftk library or php extension.
Categories : PHP, PHP Classes, PDF Click here to Update Your Picture
Juan Jaramillo
Date : Nov 24th 2009
Grade : 2 of 5 (graded 4 times)
Viewed : 9844
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Juan Jaramillo
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Need to generate FDFs but can't install the php extension / recompile? I took some code found here:
http://www.weberdev.com/get_example-4344.html

And re-wrote it as a class, which will make it easier to use..

<?php

class FdfFile {
   
    private
$fdf = null;

    public function
__construct(){
       
$this->create();
    }

    private function
create() {
       
$this->fdf['header'] = "%FDF-1.2\n%????\n1 0 obj \n<< /FDF ";
       
$this->fdf['trailer'] = ">>\nendobj\ntrailer\n<<\n/Root 1 0 R \n\n>>\n%%EOF";
    }

    public function
setFile($pdfFile) {
       
$this->fdf['file'] = $pdfFile;
    }

    public function
setTargetFrame($target) {
       
$this->fdf['target'] = $target;
    }

    public function
setValue($fieldName, $fieldValue) {
       
$this->fdf['values'] = array_merge($this->fdf['values'], array($fieldName => $fieldValue));
    }

    public function
addDocJavascript($scriptName, $script) {
       
$this->fdf['docscripts'] = array_merge($this->fdf['docscripts'], array($scriptName => $script));
    }

    public function
setJavascriptAction($fieldName, $trigger, $script) {
       
$this->fdf['fieldscripts'] = array_merge($this->fdf['fieldscripts'], array($fieldName => array($script, $trigger)));
    }

    public function
save($fdfFile = null) {
       
$search = array('\\', '(', ')');
       
$replace = array('\\\\', '\(', '\)');

       
$fdfStr = $this->fdf['header'];

       
$fdfStr.= "<< ";

        if(isset(
$this->fdf['file'])) {
           
$fdfStr.= "/F (".$this->fdf['file'].") ";
        }

        if(isset(
$this->fdf['target'])) {
           
$fdfStr.= "/Target (".$this->fdf['target'].") ";
        }

        if(isset(
$this->fdf['docscripts'])) {
           
$fdfStr.= "/JavaScript << /Doc [\n";

           
// populate the doc level javascripts
           
foreach($this->fdf['docscripts'] as $key => $value) {
               
$fdfStr.= "(".str_replace($search, $replace, $key).")(".str_replace($search, $replace, $value).")";
            }

           
$fdfStr.= "\n] >>\n";
        }

        if(isset(
$this->fdf['values']) || isset($this->fdf['fieldscripts'])) {
           
// field level
           
$fdfStr.= "/Fields [\n";

            if(isset(
$this->fdf['fieldscripts'])) {
               
// populate the field level javascripts
               
foreach($this->fdf['fieldscripts'] as $key => $val) {
                   
$fdfStr .= "<< /A << /S /JavaScript /JS (".str_replace($search, $replace, $val[0]).") >> /T (".str_replace($search, $replace, $key).") >>\n";
                }
            }

            if(isset(
$this->fdf['values'])) {
               
// populate the fields
               
foreach($this->fdf['values'] as $key => $value) {
                   
$fdfStr .= "<< /V (".str_replace($search, $replace, $value).") /T (".str_replace($search, $replace, $key).") >>\n";
                }
            }

           
$fdfStr.= "]\n";
        }

       
$fdfStr.= ">>";

       
$fdfStr.= $this->fdf['trailer'];

        if(
$fdfFile) {
           
$handle = fopen($fdfFile, 'w');
           
fwrite($handle, $fdfStr);
           
fclose($handle);
        }else {
            return
$fdfStr;
        }
    }
}
?>


Example:
<?php
    $fdf
= new FdfFile();
   
   
$fdf->setFile("http://mydomain.com/mydocument.pdf");
   
   
$str = $fdf->save( null );

   
Header("Content-type: application/vnd.fdf");
    die(
$str);
?>



Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
How To Create a PDF Using PHP
Categories : PHP, PDF, PHP Classes, HTML and PHP
PDF class - This is a useful class to make a pdf file with php functions.
Categories : PHP, PDF, PHP Classes
Url To Pdf Report By Remote Application
Categories : PHP, PHP Classes, PDF, CURL
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
Browser Detecor Class
Categories : PHP Classes, PHP, HTML
filesplit : Split big text files in multiple small ones
Categories : PHP, Log Files, Filesystem, PHP Classes
A File Browser Class.To Read Drives,Directories and Files .Files writing is also possible
Categories : PHP, PHP Classes, Filesystem
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
an example of the cyberlib payment class
Categories : PHP, PHP Classes, Ecommerce, Credit Cards
Filter - A simple class that lets you use multiple functions to create custom filters.
Categories : PHP, PHP Classes, Strings
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
DbObject - A PHP wrapper for working with various databases
Categories : Databases, PHP, PHP Classes
Simple and fast user authentication
Categories : PHP, PHP Classes, Authentication