<?php
include("../library/PODREngine.php");
include("../library/ImageOdtFilter.php");
$podr=new PODREngine(array(
"InputFileName"=>"test_image.odt",
"OutputFileName"=>"test_image_out.pdf",
"OutputMode"=>"HTTP",
));
$podr->appendFilter("load", array("ImageOdtFilter","filter"));
/**
* Filters can be defined in runtime like this, or in the template
*/
ImageOdtFilter::setImageProperty("image_replace_array", "argument", '$val[\'image\']');
ImageOdtFilter::setImageProperty("image_replace_array", "callback", 'genImageArray');
ImageOdtFilter::setImageProperty("image_replace_array", "resizeOdt", true);
//got a problem with imagepng if more than 254, too many files open
for($i=1;$i<254;$i++)
$podr->books[]=array(
'author' => 'Montesquieu',
'title' => 'Lettres persanes',
'image'=>array('width'=>$i,'text'=>'image resized'));
$podr->cols=array("author"=>"Author","title"=>"Title");
$podr->output();
function genImage($nom)
{
$im = imagecreate(150, 25);
$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 1, 5, 10, $nom, $black);
$temp=tempnam(null,"png");
imagepng($im,$temp);
imagedestroy($im);
return $temp;
}
function genImageArray($width,$text)
{
$width=($width % 200)+1;
$im = imagecreate($width, 25);
$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 1, 5, 10, $text, $black);
$temp=tempnam(null,"png");
imagepng($im,$temp);
imagedestroy($im);
return $temp;
}
?>