Giter VIP home page Giter VIP logo

fop-2's Introduction

FOP

FOP is php wrapper for Apache FOP application. Generates pdf files using xsl template

Example

include_once('/path/to/library/FOP.php');
// library configuration
$config = array();
// the only required parameter - path to xsl templates
$config['templatesRoot'] = dirname(__FILE__).'/templates/';
// optional parameter - path to apache fop application configuration. use it when you need custom fonts installation
// $config['fopConfXMLRoot'] = dirname(__FILE__).'/fop.conf';
// optional parameter - throw exceptions
// $config['debug'] = true;
// optional parameter - directory to store temporary xml files
// $config['tmpRoot'] = ‘/tmp/’;
// optional parameter - directory where fop utility installed
// $config['pathToFOP'] = ‘/path/to/fop/’;

$FOP = new FOP($config);
$version = $FOP->getVersion();
$is_installed = $FOP->isInstalled();
$configuration = $FOP->getConfiguration();

//var_dump($version);
//var_dump($is_installed);
//var_dump($configuration);

$FOP
    ->setData('var', 'hello world') // add variable into xsl template
    ->setTemplateName('example.xsl') // name of xsl template to use
    ->renderAndFlush('report') // returns saved pdf document full path and flushes it. you can use render method in order just to save it
;

Installation

Apache FOP installation is required (http://xmlgraphics.apache.org/fop/faq.html). On Ubuntu you can intall it with the following command

avb@ubuntu ~ % sudo apt-get install fop

FOP should be installed using the PEAR Installer. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0.

The PEAR channel (pear.sashabereka.com) that is used to distribute FOP needs to be registered with the local PEAR environment:

avb@ubuntu ~ % pear channel-discover pear.sashabereka.com
Adding Channel "pear.sashabereka.com" succeeded
Discovery of channel "pear.sashabereka.com" succeeded

This has to be done only once. Now the PEAR Installer can be used to install packages from the channel:

avb@ubuntu ~ % pear install sashabereka/FOP

After the installation you can find the FOP source files inside your local PEAR directory;

fop-2's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.