|Classes of Christian Vigh||PHP RTF Tools||examples/README.md||Download|
HOW TO RUN THE EXAMPLES
To run the examples, simply follow the instructions below.
Example script : beautify/beautify.php
This sample scripts simply beautifies the contents of file sample.rtf and echo them on standard output.
Example script : beautify/beautify_perf.php
This script tries, apart from beautifying sample files, tries to do a performance comparison between the RtfStringBeautifier and RtfFileBeautifier classes.
It also tests the performances of the RtfFileBeautifier class on a file which should be too large to fit into memory.
Generating the sample files
The sample file, used by the by the create\_sample.php script described above, contains the first two pages of the latest Rtf format specification from Microsoft, which you can download here :
The create\_sample.php file will allow you to create two files, generated by simply catenating several times the sample.rtf file :
Running the script
The beautify.php script generates 3 files :
The contents of bigfile.string.txt and bigfile.file.txt must be the same.
Don't be surprised if the contents of the beautified files are shorter than their original version : this is because we use here the default beautifying options, which include the BEAUTIFY\_STRIP\_IMAGE_DATA ; therefore, image contents are stripped from the output and replaced with a comment saying : "/x bytes of image data not shown/".
Example script : texter/texter.php
This script echoes on its standard output the contents of file sample.rtf, located in the same directory.
Example script : templater/templater.php
This script echoes on its standard output the contents of file sample.rtf, located in the same directory, with all the templating instructions evaluated.
Example script : merger/merger.php
This script saves in file output.rtf the merged contents of files sample1.rtf through sample4.rtf.