Previous Up Next
Xml2Pdf documentation Xml2Pdf documentation Tag pdf
Tags Xml2Pdf

Tags Xml2Pdf

Table of Contents

Guillaume Luchet, guillaume@geelweb.org
Copyright © 2006, Guillaume Luchet
BSD License

Tags manual

Create tags

The tags recognize by Xml2Pdf are define using plugins files. To create a new tag, you must just create a new plugin file and put it in the plugins tags directory who is defined in the config file Xml2Pdf.config.php

eg, to create a tag custom, you must create a file named xml2pdf.tag.custom.php with a class named Xml2PdfTag_custom.

The plugin class must have the following methods :

  • void __construtc(object Pdf, array) or void __construct(object Pdf, array, object Pdf)

  • void addContent(string)

  • void close()

If the constructor take three parameters, the third will be the parent tag of the curent tag.

example :

  1. class Xml2PdfTag_custom {
  2.     /**
  3.      * parent tag
  4.      * @var object 
  5.      */
  6.     public $parent;
  7.  
  8.     /**
  9.      * object Pdf.
  10.      * @var object 
  11.      */
  12.     public $pdf;
  13.  
  14.     /**
  15.      * tag content
  16.      * @var string 
  17.      */
  18.     public $content;
  19.  
  20.     /**
  21.      * Constructor.
  22.      *
  23.      * call when the tag custom is open.
  24.      *
  25.      * @param object $pdf Object Pdf
  26.      * @param array $tagProperties tag properties
  27.      * @param object $parent tag parent
  28.      * @return void 
  29.      */
  30.     public function __construct($pdf$tagProperties$parent{
  31.         // here you can parse the tag properties
  32.     }
  33.  
  34.     /**
  35.      * add the content
  36.      *
  37.      * @param string $content tag content
  38.      * @return void 
  39.      */
  40.     public function addContent($content{
  41.         // here you can manage the content
  42.     }
  43.  
  44.     /**
  45.      * call when the tag is closed
  46.      *
  47.      * @return void 
  48.      */
  49.     public function close({
  50.         // here you can maange the actions to do when the tag is closed
  51.     }
  52. }

To the following XML :

<parent foo="foovalue">
  <custom bar="barvalue">custom tag content.</custom>
</parent>
            
The PHP code will be :
  1. // <parent foo="foovalue">
  2. require_once('xml2pdf.tag_parent.php');
  3. $parentTag new Xml2PdfTag_parent($pdfObjectarray('FOO'=>'foovalue'));
  4.  
  5. // <custom bar="barvalue">
  6. require_once('xml2pdf.tag_custom.php');
  7. $customTag new Xml2PdfTag_custom($pdfObjectarray('BAR'=>'barvalue')$parentTag);
  8.  
  9. // custom tag content.
  10. $customTag->addContent('custom tag content.');
  11.  
  12. // </custom>
  13. $customTag->close();
  14.  
  15. // </parent>
  16. $parentTag->close();

Existing tags

The existing tags plugins are :

Previous Up Next
Xml2Pdf documentation Xml2Pdf documentation Tag pdf

Documentation generated on Wed, 11 Oct 2006 22:27:05 +0200 by phpDocumentor 1.3.0