# Document Generator Class [RTF PDF]

http://paggard.com/projects/doc.generator/

[^ up]

## Introduction

Document Generator Class is aiming to unify the generation of the printable documents using the common file formats - RTF and PDF. There are a lot of situations, when there is a need of some application which could form certain information in a format, which could be easily downloaded from internet server and then opened, printed or saved by any internet user, and this class can help the owners of various web services to accommodate this need.

This script is written in PHP and uses no additional components (plugins or else). Only if you are planning to generate documents in different character sets - you will need to make sure that 'mbstring' extension (which is included into the standard PHP distribution packet) is enabled in your PHP.ini file. The script works on Unix or Win32 platforms and require only PHP 4.x.x (or later) installed. As there is no plugins required for the script to work, it could be easily installed on server, or even be used in a local network to create some reports, or anything else.

The script uses special markup language, based on XML rules. The language is very flexible and allow to create perfect-looking documents as there are a lot of options available to control document look.

With this script it is possible to create very complicated tables having full control over their look at the same time. It is possible to merge cells, change background color, control width and height of the cells. Even nested tables are supported, only you need to remember that this is not HTML, and nested tables will not always look like they do in HTML.

The script supports images (.JPG and .PNG) which could be inserted into your document. Besides it supports multiple pages layout with page numbering, headers and footers.

IMPORTANT!: PDF driver is currently under development, and does not yet support all the features the RTF driver does. For the list of current known issues and differencies, please, consult the online list: http://paggard.com/projects/doc.generator/pdf_known_issues.html

[^ up]

## Key Features

Here is the list of supported features:

- Font face, style, size, color control
- Advanced paragraphs control
- Document sections and multipage control
- Page numbering
- Document headers and footers, including support for facing pages
- PNG & JPG images support
- Tables support including row and col spans and nested tables
- Hyperlinks within and outside the document
- Footnotes
- Hidden text
- Columns
- Tabulations
- Symbols support
- Multilanguage support, including UTF-8
- HTML entities support

and the list will be growing.

[^ up]

## Requirements

The script has minimum requirements to run. The only main requirement is PHP 4.x.x or later installed. The script does not require additional modules, only if you plan to use different languages - you need to make sure that "mbstring" PHP extention is enabled. This extension is included into the default PHP package, but you need to make sure that it is enabled on the server where you plan to use the script.

the script can work on any operation system that has PHP engine installed.

[^ up]

## Usage Example

The script installation is pretty simple. As it uses only PHP, it doesn't have any other requirements. To install the script you should only unpack in a server folder and that's all - it is ready to use. If you are planning to save the ready documents on your server - you will need to make sure that the target folder has the correct permissions for writing.

To generate document you'll need just a few lines of PHP code. You should create a Class object, then pass XML template to it and receive ready document code. After that you could either pass this code to the user as a file stream or save it to disk for future use.

There are many ways how you can create XML template for the Generator - you can create is dynamically during the execution of the PHP script, store is into the php variable and then pass to the Generator, or you can create the template, store it on disc and then use by the Generator. If you are not sure what is the best way for your task - you can always consult with me.

Here is the simplest example of using the script, in this example ready XML template stored on disc will be used and the result file will be passed to user as a file stream:

This is very simple example of creation of an .rtf file:

    <?php

        require_once "document_generator/cl_xml2driver.php";

        // this will be the name of our RTF file:

        $file_rtf = "Test.rtf";

        // HTTP headers saying that it is a file stream:

        Header("Content-type: application/octet-stream");

        // passing the name of the streaming file:

        Header("Content-Disposition: attachment; filename=$file_rtf");

        // example XML template

        $file = "example_template.xml";

        $xml_template = join("",file($file));

        // creating class object specifying the driver type - "RTF"

        $xml = new nDOCGEN($xml_template,"RTF");

        echo $xml->get_result_file();

    ?>

Another example of the script shows how to save RTF file to disc:

    <?php

        require_once "document_generator/cl_xml2driver.php";

        // this will be the name of our RTF file:

        $file_rtf = "Test.rtf";

        // example XML template

        $file = "example_template.xml";

        $xml_template = join("",file($file));

        // creating class object specifying the driver type - "RTF"

        $xml = new nDOCGEN($xml_template,"RTF");

        $fp = fopen($file_rtf, "w");

        fwrite($fp, $xml->get_result_file());

        @fclose($fp);

    ?>

PDF files are generated with the same code - only you will need to give 'PDF' as driver name, and have '.pdf' extention for the target file.
Other sample scripts, showing different ways of using the script - you can find in the distribution package.

### Using temporary files

PHP is using `memory_limit`, which is by default set to '8M', but this may not be enough if you are dealing with the large files with a lot of images. To be able to handle these situations the script can use temporary directories instead of memory. Also, this greatly increases the generation time of files with a lot of images.

To turn this feature on you will need to set the path to your temporary dir in the main configuration file, like this:
`$temp_dir = "tmp/";`
* be sure to include the trailing slash!
* you should set the permissions so, that the script will be able to create files in this directory!

If using temporary directory, you should not use `$xml->get_result_file();` function anymore. Instead, you will need to use one of the functions below:
`$xml->get_doc_stream();` - for streaming the file to the user or
`$xml->get_doc_to_file("path/to/file/","file_name");` - for saving the file to disc

Below are the modified usage examples to be used with temporary directories:

Simple example of creation of an .xls file and streaming it ot the user with `temp_dir`:

    <?php

        require_once "document_generator/cl_xml2driver.php";

        // this will be the name of our RTF file:

        $file_rtf = "Test.rtf";

        // HTTP headers saying that it is a file stream:

        Header("Content-type: application/octet-stream");

        // passing the name of the streaming file:

        Header("Content-Disposition: attachment; filename=$file_rtf");

        // example XML template

        $file = "example_template.xml";

        $xml_template = join("",file($file));

        // creating class object specifying the driver type - "RTF"

        $xml = new nDOCGEN($xml_template,"RTF");

        $xml->get_doc_stream();

    ?>

Example of the script shows how to save RTF file to disc with `temp_dir`:

    <?php

        require_once "document_generator/cl_xml2driver.php";

        // this will be the name of our RTF file:

        $file_rtf = "temp_dir.rtf";

        // example XML template

        $file = "example_template.xml";

        $xml_template = join("",file($file));

        // creating class object specifying the driver type - "RTF"

        $xml = new nDOCGEN($xml_template,"RTF");

        $xml->get_doc_to_file("",$file_rtf);

        echo "Generated file <b>".$file_rtf."</b> was saved to disc.";

    ?>

[^ up]

## Multiple character sets support

The script supports different character sets for your documents. to enable the support of this feature `$multilingual_support` variable in the configuration file should be set to '`true`'. Another requirement - you need to have "mbstring" PHP extention enabled. This extension is included into the default PHP package, but you need to make sure that it is enabled on the server where you plan to use the script. For the XML to be able to process the templates in character sets other than ANSI, you will need to provide additional 'encoding' option in the main xml tag, something like this:

    <?xml version="1.0"  encoding="ISO-8859-1" ?>
    ...

or

    <?xml version="1.0"  encoding="UTF-8" ?>
    ...

Idealy, the 'encoding option should represent the actual encoding of the contents of the template. If the correct encoding is provided, the script will do the decoding and inserting automatically. Also, there are some advanced controls in the configuration file, but they are just in case of some 'fine tuning'.

IMPORTANT! - If you are not sure, if the necessary language is supported - you can always contact me directly and ask for support - I'm always willing to help. Also - the 'multilingual' capabilities of RTF and PDF formats are different, that is why PDF may not support all the languages that RTF does.

In addition to all said above, there is a way to insert single UNICODE characters directly from template without even enabling the `$multilingual_support`. This can be done either by using HTML entities or by using the character UNICODE number in a construction like this: `&#U`+UNICODE_NUMBER. Example:

    EURO SIGN : &#U8364

The unicode numbers for different characters can be found in the Internet, here is an example page:
http://www.pemberley.com/janeinfo/latin1.html

[^ up]

## Rules

When creating a template for Document Generator you should stick to the following rules:

1. Every template should have the very first line like this: `<?xml version="1.0" ?>`
   If you are dealing with various character sets, you might need to add the 'encoding' option:
   `<?xml version="1.0" encoding="ISO-8859-1" ?>` or
   `<?xml version="1.0" encoding="UTF-8" ?>`
2. The template body should always be enclosed into `<DOC> .... </DOC>` tag.
3. Every tag should have a closing tag :
   `<DOC> ... </DOC>` or `<BR />`.
4. All options in the tags should be enclosed into quotes :
   `<font face="roman">` some text `</font>`
5. RTF driver allows to use short paragraph tag: `<P />`, while PDF driver requires that all paragraph text should be included into `<P>` ... `</P>` tags. Keep this in mind if you are planning to use the same templates for generating RTF & PDF files.
6. Do not try to use "impossible" tables. If table tags are placed incorrectly - the result is unpredictable.
7. Nested tables can not have the widthts given in'%' - only specific measurements will work.

[^ up]

## Tags Reference

To prepare a good-looking document you will need to use different tags which allow apply different formatting properties to your document.

[^ up]

### DOCUMENT tag

This is the main tag for the template. Each template should have its body enclosed into this tag. The tag defines the global document options and configuration.

usage: `<DOC config_file= [title] [subject] [author] [manager] [company] [operator] [category] [keywords] [comment] />`

- `config_file=` - this option is oligatory and should contain path to the configuration file
- `title=` - document property 'Title'
- `subject=` - document property 'Subject'
- `author=` - document property 'Author'
- `manager=` - document property 'Manager'
- `company=` - document property 'Company'
- `operator=` - document property 'Operator'
- `category=` - document property 'Category'
- `keywords=` - document property 'Keywords'
- `comment=` - document property 'Comments'

example:

    <?xml version="1.0" ?>
    <DOC
    config_file="document_generator/doc_config.inc"
    title="Test Document"
    subject="Illustrating the Generator Features"
    author="Paggard.com"
    manager="Paggard"
    company="Paggard.com"
    operator="scripting"
    category="general documents"
    keywords="rtf php create generator"
    comment="for testing purposes"
    >
    ...

    template body

    ...

    </DOC>

[^ up]

### General tags

General tags are used to design your text in general. With the help of these tags you can create bold, italic, underlined text. Besides it is possible to create subscript and superscript, and insert line-breaks. These tags are identical to HTML tags.

### Bold text

purpose: to create bold text
usage: `<b>`this text will be bold`</b>`

### Italic text

purpose: to create italic text
usage: `<i>`this text will be italic`</i>`

### Underlined text

purpose: to underline text
usage: `<u>`this text will be underlined`</u>`

### Superscript

purpose: to create superscript text
usage: `<sup>`this text will be lifted up`</sup>`

### Subscript

purpose: to create subscript text
usage: `<sub>`this text will be lowered`</sub>`

### New line

purpose: to start new line
usage: `<br />`This is a new line.
* Do not mix this tag with paragraph tag, it is just a line break.

### Horizontal rule

purpose: to create horisontal rule
usage: `<hr [size] [style] />`

It is possible to control the thickness and style of the rule.

- `size=` - numeric value to control thickness
- `style=` - the code for the line style. Can be one of the following:
  - `SHADOWED`: Shadowed.
  - `DOUBLE`: Double.
  - `DOTTED`: Dotted.
  - `DASHED`: Dashed.
  - `HAIRLINE`: Hairline.
  - `INSET`: Inset.
  - `DASH`: Dash (small).
  - `DOT`: Dot dash.
  - `DDDASH`: Dot dot dash.
  - `OUTSET`: Outset.
  - `TRIPLE`: Triple.
  - `WAVY`: Wavy.
  - `DOUBLEW`: Double wavy.
  - `STRIPED`: Striped.
  - `EMBOSS`: Emboss.
  - `ENGRAVE`: Engrave.

example:

    <hr size="50" style="DOTTED" />

[^ up]

### Font tag

purpose: This tag is used to set font parameters of the text
usage: `<font [size] [face] [color]>`any text`</font>`

It is possible to control the size, face and color of the font. Size should be in points. Font color should be only in `#XXXXXX` format, no color names like "`black`", "`red`" or alike.

- `face="symbol"` - Symbols
- `face="arial"` - Arial
- `face="arial"` - Arial
- `face="roman"` - Times New Roman
- `face="cur"` - Courier
- `face="courier"` - Courier New
- `face="seriff"` - Microsoft Sans Serif
- `face="garamond"` - Garamond
- `face="verdana"` - Verdana
- `face="helvetica"` - Helvetica

example:

    <font size="14" face="roman" color="#FF0000">
    This text will be 14 point in size and have face Times New Roman and the text will be red
    </font>

[^ up]

### Paragraph tag

purpose: This tag is used to set paragraph formatting
usage: `<p [align] [before] [after] [lines] [lindent] [rindent] [findent] [lead] [tsize]>`Paragraph text

- `align=` - paragraph alignment
  - `right` - right aligned
  - `left` - left aligned
  - `center` - centered
  - `justify` - justified
- `before=` - space before(mm)
- `after=` - space after(mm)
- `lines=` - space between lines(mm), if 0 - minimal is taken
- `lindent=` - left indent (mm)
- `rindent=` - right indent (mm)
- `findent=` - first line indent (mm)

Below are the tabulation controls, they are used to control position and the filling of the tabulations `<tab>`

- `lead=` - determines the filling for the tabulation, if there are several tabulations within the paragraph, the leadings values should be divided by ","
  - `dot`
  - `mdot`
  - `hyph`
  - `ul`
  - `th`
  - `eq`
- `tsize=` - tabulation sizes (mm) - if there are several tabulations within the paragraph, the sizes values should be divided by ","
- `talign=` - tab alignment
  - `right`
  - `center`
  - `decimal`

tabulation example:

    <p lead="dot,dot" tsize="50,100" />Name<tab />price1<tab />price2
    <p lead="dot,dot" tsize="50,100" />Customer 1<tab />23<tab />56
    <p lead="dot,dot" tsize="50,100" />Customer 2<tab />40<tab />60

To understand the system of tabulations it is better to perform some tests by yourself

paragraph example:

    <p align="right" before="10" after="0" lines="0" lindent="10" rindent="0" findent="-5" >
    This paragraph will be right-aligned, the space before the paragraph will be 10 millimeters,
    the space after the paragraph will be minimal, space between lines - minimal,
    the paragraph will be indented from left margin by 10 millimeters, from right margin -
    by 0 millimeters and the first line of the paragraph protrudes by 5 millimeters.
    </p>

[^ up]

### Image tag

purpose: This tag is used to images into your document
usage: `<img src= width= height= [border] [wrap] [align] [anchor] [left] [top] [space] [script]>`

With the help of this tag you can insert images into your documents. The script supports two image formats - .JPG and .PNG. The images can be inserted either from a local disk, from internet or can be generated by the some other script. The script provides full control over image size, position and alignment. Besides special option is introduced to control text wrapping. Also, in the configuration file there is a possibility to limit the maximum image size.

- `src=` - image URL or local path (obligatory)
- `width=` - image width in mm (obligatory)
- `height=` - image height in mm (obligatory)
- `wrap=` - text wrap type
  - `no` - none (wrap as if image isn't present) - no wrap, image is behind the text
  - `around` - wrap tightly around shape
  - `updown` - wrap around top and bottom of shape (no text allowed beside shape)
- `align=` - image align
  - `center` - centered
  - `right` - right aligned
  - `left` - left aligned
- `border=` - image border
  - `0` - no image border
  - `1` - the image will have border
- `anchor=` - image anchor
  - `para` - anchor is linked to the current paragraph
  - `page` - anchor is linked to the current page
  - `margin` - anchor is linked to the margins of the page
  - `INCELL` - this anchor is used to place an image within a table cell.
- `left=` - position of shape from the left of the anchor in mm
- `top=` - position of shape from top of the anchor in mm
- `space=` - wrapping dispance from the image in mm
- `script=` - ***this option is for images that are generated dynamically by scripts.
  - `jpg` - set this parameter if the generated image is JPG format
  - `png` - set this parameter if the generated image is PNG format

* mm - means millimeters, don't try to use pixels as in HTML the page have certain size in millimeters and all the measurements should be in millimeters.
** obligatory - means that this option must be present in this tag to guarantee correct image representation.
*** if you are using script-generated images - make sure that you are using '`http://`' call, because the script first should be executed by server and generate an image, and after that this image will be read by Generator.

example:

    1. <img src="logo.png" width="60" height="14" wrap="around" align="left" border="1" anchor="page" />
    2. <img
    	src="http://your_server.com/get_image.php?get_var=345"
    	script="jpg" width="60" height="14"
    	wrap="around" align="left" border="1" anchor="page"
       />

[^ up]

### Table tags

purpose: This tag is used to create tables in your document.
usage: `<table [border] [align] [valign] [width] [bgcolor] [bord_color] [color] [rowkeep] [tablekeep]>
`

  <tr [border] [align] [valign] [bgcolor] [color]>
  <td [border] [align] [valign] [bgcolor] [color]>table cell text`</td>
  `
  </tr>
  </table>

  These tag gives you the possibility to create very complicated and good-looking tables. You can also 'nest' the table tags to include one table into the cell of another table - but in this case make sure the table widths do not conflict with each other.

  - `<table [border] [align] [valign] [width] [bgcolor] [bord_color] [color] [rowkeep] [tablekeep]>`...`</table>` - the whole table settings
    - `border=` - table border (`0` - no; `1` - yes - or string value like "`t,b,r,l`" - means: top,bottom,right,left border)
    - `bord_color=` - table border color in HEX - example - `#ff00ff`
    - `align=` - horizontal table alignment on the page
      - `right` - right aligned
      - `left` - left aligned
      - `center` - centered
      - `justify` - justified
    - `valign=` - vertical alignment for all the table cells
      - `top` - top aligned
      - `middle` - middle aligned
      - `bottom` - bottom aligned
    - `width=` - table width (either in mm or in percent from page width - example - 50%)
    - `bgcolor=` - table background in percent from black - example - 50 (50% of gray)
    - `color=` - table background color in HEX - example - `#ff00ff`
    - `rowkeep=` `yes`- prevent table rows from splitting between pages
    - `tablekeep=` `yes`- keeps all table rows on single page
  - `<tr [height] [border] [align] [valign] [bgcolor] [color]>` ... `</tr>` - table row settings
    - `height=` - vertical height of a given row
    - `border=` - row border (`0` - no; `1` - yes - or string value like "`t,b,r,l`" - means: top,bottom,right,left border) - if omitted - is taken from table settings
    - `align=` - horizontal alignment for the row - if omitted - is taken from default settings
      - `right` - right aligned
      - `left` - left aligned
      - `center` - centered
      - `justify` - justified
    - `valign=` - vertical alignment for the text in row cells - if omitted - is taken from table settings
      - `top` - top aligned
      - `middle` - middle aligned
      - `bottom` - bottom aligned
    - `bgcolor=` - row background in percent from black - example - 50 (50% of gray - if omitted - is taken from table settings
    - `color=` - row background color in HEX - example - `#ff00ff` - if omitted the value is taken from table settings
  - `<td [border] [align] [valign] [bgcolor] [color]>`cell text`</td >`- cell settings
    - `colspan=` - number of colomns spanned by the cell
    - `rowspan=` -number of rows spanned by the cell
    - `border=` - cell border (`0` - no; `1` - yes - or string value like "`t,b,r,l`" - means: top,bottom,right,left border) - if omitted - is taken from row settings
    - `align=` - horizontal alignment for the cell - if omitted - is taken from row settings
      - `right` - right aligned
      - `left` - left aligned
      - `center` - centered
      - `justify` - justified
    - `valign=` - vertical alignment for the cell - if omitted - is taken from row settings
      - `top` - top aligned
      - `middle` - middle aligned
      - `bottom` - bottom aligned
    - `width=` - cell width (either in mm or in percent from table width - example - 30%)
    - `bgcolor=` - cell background in percent from black - example - `50` (50% of gray - if omitted - is taken from row settings
    - `color=` - cell background color in HEX - example - `#ff00ff` - if omitted the value is taken from row settings
  * be careful when using colspan and rowspan tags - if you're trying to build impossible table - the result will be unpredictable
  ** if some options are omitted they are taken from the default settings, which are set in the configuration file

  example:

      <table width="100" border="1">
         <tr>
            <td colspan="2" bgcolor="30" valign="top">First cell</td>
         </tr>
         <tr>
            <td align="left" color="#ff0000">next cells</td><td align="right">another one</td>
         </tr>
      </table>

[^ up]

### Multi-page control

Using this set of tags you will be able to create multi-paged documents with the possibility to control page layout. You can insert headers and footers, number the pages through the whole document, insert page breaks.

### Page break

purpose: to start new page
usage: `<page />`

Just place this tag where you need to start a new page.

### Headers and footers

To avoid compatibility problems between RTF and PDF - headers and footest shoul always be defined either in the beginning of the template (after `<DOC>` tag) or right after the `<SECTION>` tag.

purpose: to create headers and footers for all the document pages
usage: `<header>`Your header text`</header>`

  `<footer>`Your footer text `</footer>`

  The script supports 'facing' pages, when right and left pages can have separate headers and footers. the 'Facint pages' feature can be activated in the main configuration file. There are also additional controls for this feature. Once activated - you can use additional tags to define headers and footers:
  `<headerr>`Your header text`</headerr>` - to define header for right pages
  `<headerl>`Your header text`</headerl>` - to define header for left pages
  `<footerr>`Your footer text`</footerr>` - to define footer for right pages
  `<footerl>`Your footer text`</footerl>` - to define footer for left pages

  For header and footer you can use all the tags to describe text formatting bold, italic (general tags). You can even put tables and images into the page headers and footers - in this case these element will be repeated on every page. The alignment of header and footer is set in the main configuration file. Also - each document section can have separate set of headers and footers

### Page numbers

Another feature of the script - page numbers. The settings are in the main configuration file. There is almost full control under the page numbers - start value, vertical and horizontal alignment. It is possible to enable or disable the page numbers autoinsetion, if disabled - you can insert the page number and the total number of pages using the following tags:
`<cpagenum />` - current page number
`<tpagenum />` - total number of pages

Also, page numbers can be controlled by document sections.

### Document sections

Another significant feature of the script is 'document sections'. The point is that you can handle different sections within one document. Every section can have its own page numbering, headers and footers. The section tag is much like page break tag - so they should not be put together, or you'll get an empty page within your document.

usage: `<section [pn_start] [pn_align] [nobreak] [landscape] [columns]>`

- `pn_start=` - beginning page number
- `pn_align=` - [`left` / `center` / `right`] horisontal alignment of the page numbers
- `nobreak=` - [`yes`] applying new section without starting a new page
- `landscape=` - [`yes`] landscape page orientation within the section (default is portrait)
- `columns=` - [number of columns] the number of columns to divide the text within the section

To create headers and footers for the section, just place appropriate tags after the section tag. The vertical alignment of the page numbers through the whole document is set in the configuration file.

[^ up]

### Hyperlinks

purpose: Hyperlinks can be used for providing navigation within and outside the document

Navigation within the document:
usage: `<a local="go_to_this_id">`any text`</a>`

  . . .
  `<id name="go_to_this_id" />`

  Navigation outside the document:
  usage: `<a file="path_to_file">`any text`</a>` - mind that "`file`" should be one_word

  By using this feature you can organize something like table of contents or anything else with the possibility of jumping from one to the other parts of the documents. Also you can create links to the other documents to be opened using one mouse click. In MS Word you will need to do CTRL+Click to follow the link.

[^ up]

### Footnotes

purpose: Footnotes are used in printed documents to explain, comment on, or provide references for text in a document. You might use footnotes for detailed comments. Footnotes are located at the bottom of each page and has automatic numbering

usage: Any paragraph text`<footnote>`your footnote text`</footnote>` continuation of paragraph text.

To control the appearance of the footnotes you can use special settings in the configuration file under the 'DEFAULT FOOTNOTES SETTINGS' section. You will be able to control color, font face, font size and font decoration.

[^ up]

### Hidden text

purpose: Another small feature, that allows you to hide the block of text. After the text is hidden it can be viewed in MS Word (for example) by using 'Show/Hide' button

usage: `<hidden>`the text you want to hide`</hidden>`

## Additional materials

[^ up]

## Main Configuration File

Here is the example of the script configuration file with explanations.

    <?php

    //    CONFIGURATION FILE FOR DOCUMENT GENERATOR CLASS

    //    SOME OF THESE SETTINGS COULD BE OVERWRITTEN BY USING SPECIAL TAGS

    //    IN CASE OF OMMITTING THE TAGS, TEXT IS FORMATTED USING THESE SETTINGS

    $temp_dir = false; // this variable is used to reduce the memory usage when dealing

                       // with great amount of images. This variable should contain

                       // either 'false' or the full path to the temp directory

                       // WITH TRAILING SLASH - like this : "tmp/"

                       // please, monitor this directory as though the temporary files

                       // are deleted automatically, there is still a chance that

                       // some of them can remain due to some external reasons

                       // that can not be controlled by the script

                       // IMPORTANT!!!

                       // if using temporary directory you should not use 'get_rtf()' function

                       // use either $xml->get_doc_stream();  or

                       // $xml->get_doc_to_file("path/to/file/","file_name");

    /////

    // ATTENTION!

    // all measurements are given in millimeters, but you can use the following units:

    //  'cm'   : //centimeters

    //  'mm'   : //millimeters

    //  'q'    : //alias of 'kyu'

    //  'kyu'  : //Q/kyu

    //  'in'   : //inches

    //  'pt'   : //alias of 'pts' (points)

    //  'pts'  : //points

    //  'picas': //picas

    //  'twips': //twips

    /////

    // ALSO - you can set special units everywhere, example:

    //  $pg_height="12in"; // will mean 12 inches

    //  <table width=2cm> // will set table width to 2 cm

    // and alike.

    $default_units = "mm"; // default measurement units

    //---------------------------------------------------

    // DEFAULT PAGE SETTINGS

    //---------------------------------------------------

    $pg_width=210;   // page width (mm)

    $pg_height=297;  // page height (mm)

    $mar_left=19;    // left margin width (mm)

    $mar_right=19;   // right margin width (mm)

    $mar_top=19;     // top margin height (mm)

    $mar_bott=19;    // bottom margin height (mm)

    $facing_pages = 1; // 1 - activates activates odd/even headers and gutters;

                       // 0 - deactivates

    $gutter_width = 5; // Gutter width (when $facing_pages is activated)

    $rtl_gutter = 1;   // if 1 - Gutter is positioned on the right

    $page_orientation = "portrait"; // portrait or landscape

    //$page_orientation = "landscape"; // portrait or landscape

    $header_align = "right"; // default header align - "left", "right", "center"

    $footer_align = "left"; // default footer align - "left", "right", "center"

    $head_y=1; // space between the top edge of the page and the top header (mm)

    $foot_y=10; // space between the bottom edge of the page and the bottom footer (mm)

    $page_numbers = 1; // page numbers, if  < 0 - no page numbers; if >= 0 page numbers start from the specified number

    $page_numbers_valign = "bottom"; // vertical alignment of the page numbers ("top" or "bottom")

    $page_numbers_align = "center"; // horisontal alignment of the page numbers ("left", "center", "right")

    $page_numbers_autoinsert = "0"; // 0 = disable, 1 = enable autoinsertion.

                                    // Use <cpagenum /> to insert pagenumber when disabled.

                                    // Use <tpagenum /> to insert the total number of pages.

                                    // Valign and align only work in enabled mode

    //---------------------------------------------------

    // DEFAULT HYPER LINK SETTINGS

    //---------------------------------------------------

    $h_link_color = "#009900"; // default color for hyper links

    $h_link_fontf = "garamond"; // default link font face [arial,roman,sym,courier,seriff,garamond]

    $h_link_fonts = "12"; // default link font size in pt

    $h_link_fontd = "i"; // default link decoration [ul - underline, i - italic, b - old]

    //---------------------------------------------------

    // DEFAULT FOOTNOTES SETTINGS

    //---------------------------------------------------

    $fnt_color = "#660099"; // default color for footnotes

    $fnt_fontf = "garamond"; // default footnote font face [arial,roman,sym,courier,seriff,garamond]

    $fnt_fonts = "10"; // default footnote font size in pt

    $fnt_fontd = ""; // default footnote decoration [ul - underline, i - italic, b - old]

    //---------------------------------------------------

    // DEFAULT FONT AND PARAGRAPH SETTINGS

    //---------------------------------------------------

    $font_face = "arial"; // default font face [arial,roman,sym,courier,seriff,garamond]

    $font_size = "10";  // font size in pt

    $def_par_before = "0"; // space before paragraph (mm) (better set to 0, when using tables and set by tag)

    $def_par_after = "0"; // space after paragraph (mm) (better set to 0, when using tables and set by tag)

    $def_par_align = "left"; // default paragraph align.

                                         // "left", "right", "center", "justify"

    $def_par_lines = 0; // space between lines (mm). if 0 - minimal is taken

    $def_par_lindent = "0"; // paragraph left indent (mm) (better set by tag)

    $def_par_rindent = "0"; // paragraph right indent (mm) (better set by tag)

    $def_par_findent = "0"; // first line indent (mm) (better set by tag)

    //---------------------------------------------------

    // DEFAULT TABLE SETTINGS

    //---------------------------------------------------

    $tbl_def_border = 1; // table border (1 - yes; 0 - no) or string value:

                         //   "t,b,r,l" - means: top,bottom,right,left borders

                         //   you can vary these letters to get the result you need

    $tbl_def_width = "100%"; // table width (in mm or in % from page width)

    $tbl_def_cellpadding = 0; // default cellpadding (mm)

    $tbl_def_align = "left"; // default table align on the page (center, right, left)

    $tbl_def_valign = "top";// default vertical text align for all the cells (top, middle, bottom)

    $tbl_def_bgcolor = "0"; // table background (0 - no, or % from black)

    $row_def_align = "left"; // default horizontal text align for all the cells (center, right, left)

    //---------------------------------------------------

    // DEFAULT IMAGE SETTINGS

    //---------------------------------------------------

    $image_size = 5000; // maximum allowed image size in kb

    $img_def_border = 0; // image border (1 - yes; 0 - no)

    $img_def_src = "";  // default image src (used when no, or a bad source specified)

    $img_def_width = 20; // default image width (mm)

    $img_def_height = 20; // default image height (mm)

    $img_def_left = 0; // space between the anchor and image left edge (mm)

    $img_def_top = 0; // space between the anchor and image top edge (mm)

    $img_def_space = 5; // space between the image and the text (mm)

    $img_def_align = "left"; // image align on the page (center, right, left)

    $img_def_wrap = "around"; // type of text wrapping for image (no, updown, around)

    $img_def_anchor = "par"; // linking anchor for image

                             // para = image is linked to the current paragraph

                             // page = image is linked to the current page (top left page corner)

                             // margin = image is linked to margin (top left page corner including margins)

    //---------------------------------------------------

    // MULTILINGUAL SUPPORT

    //---------------------------------------------------

    $multilingual_support = true; // if you need to create document with characters outside

                                            // ASCII table - uou need this to be 'true'

                                            // also - you need to have 'mbstring' PHP extention enabled

    /*

    --- ENCODING DEPENDENCIES ---

    language        charset         encoding

    ==============================================

    FRENCH          0               ISO-8859-1

    GERMAN          0               ISO-8859-1

    SPANISH         0               ISO-8859-1

    SWEDISH         0               ISO-8859-1

    RUSSIAN         204             Windows-1251

    */

    ////  FONT CHARACTER SET

    $default_charset = 0; // sets default character set

    /*

    ANSI                   = 0

    Default                = 1

    Symbol                 = 2

    Invalid                = 3

    Mac                    = 77

    Shift Jis              = 128

    Hangul                 = 129

    Johab                  = 130

    GB2312                 = 134

    Big5                   = 136

    Greek                  = 161

    Turkish                = 162

    Vietnamese             = 163

    Hebrew                 = 177

    Arabic                 = 178

    Arabic Traditional     = 179

    Arabic user            = 180

    Hebrew user            = 181

    Baltic                 = 186

    Russian                = 204

    Thai                   = 222

    238Eastern European    = 238

    PC 437                 = 254

    OEM                    = 255

    */

    ?>

[^ up]

## Author & Copyright

License Agreement:

If you buy Document Generator you can use it as you like it and anywhere you will need it. You can do what ever you want with it except selling the script itself. If you're going to include my script into some commercial project for selling, you should include the script price into the budget and every of your customer should together with your software buy the license for my script. It is also possible to buy a distribution license for the script. If you have other plans - we can discuss them.

Vadim Kiparenko paggard@paggard.com
If you will have any question of suggestions - feel free to contact me directly - I'll try to respond as soon as possible.

© 2007. All Rights Reserved. This class is a commercial software, if you are interested in purchasing it - contact me.