";
return false;
}
//get the only child
foreach($doc->childNodes as $child) {
if ($child != NULL &&
$child->nodeName == "fo:root") {
$rootNode = $child;
}
}
if ($rootNode == null) {
echo "Didn't find root node
";
return false;
}
// oesi - Format und orientation auslesen
$masterpage = $rootNode->getElementsByTagName('simple-page-master');
$format = 'A4';
$orient = 'P';
foreach ($masterpage as $x=>$mp)
{
if($mp->getAttribute('format')!='')
$format = $mp->getAttribute('format');
if($mp->getAttribute('orientation')!='')
$orient = $mp->getAttribute('orientation');
}
$pdf = new MyPDF($orient, 'mm', $format);
$root = new FO_Root($pdf);
$this->initDefaults($pdf, $root);
if ($root->parse($rootNode) === false) {
echo "Parsing failed
";
return false;
}
if (strpos($name, ".pdf")===false) {
$name = $name.".pdf";
}
$pdf->Output($name, $dest);
return true;
}
function initDefaults(FPDF $pdf, FO_Root $root) {
$pdf->SetFont('Arial','',14);
$pdf->SetAutoPageBreak(true);
$root->setContext("page-width", "21");
}
}
class FO_Factory {
static $factory = array("fo:layout-master-set" => 'FO_LayoutMasterSet',
"fo:block" => 'FO_Block',
"fo:page-sequence" => 'FO_PageSequence',
"fo:flow" => 'FO_Flow',
"fo:block-container" => 'FO_BlockContainer',
"fo:list-block" => 'FO_ListBlock',
"fo:table-and-caption" => 'FO_TableAndCaption',
"fo:table" => 'FO_Table',
"fo:table-caption" => 'FO_TableCaption',
"fo:table-header" => 'FO_TableHeader',
"fo:table-footer" => 'FO_TableFooter',
"fo:table-body" => 'FO_TableBody',
"fo:table-row" => 'FO_TableRow',
"fo:table-column" => 'FO_TableColumn',
"fo:table-cell" => 'FO_TableCell',
"fo:inline" => 'FO_Inline',
"fo:instream-foreign-object" =>
'FO_InstreamForeignObject',
"fo:basic-link" => 'FO_BasicLink',
"fo:external-graphic" => 'FO_ExternalGraphic',
"svg:svg" => 'FO_SVG',
"svg:circle" => 'SVG_Circle',
"svg:rect" => 'SVG_Rect',
"svg:ellipse" => 'SVG_Ellipse',
"svg:line" => 'SVG_Line',
"svg:polygon" => 'SVG_Polygon',
"svg:polyline" => 'SVG_Polygon',
"svg:g" => 'SVG_G',
"svg:text" => 'SVG_Text',
"svg:path" => 'SVG_Path'
);
static $names = NULL;
static function createFOObject(DOMNode $node, FO_Container $container,
FPDF $pdf, FO_Context &$context,
$filter)
{
if(isset(self::$factory[$node->nodeName]))
$obj = self::$factory[$node->nodeName];
if (!isset($obj) || !$obj)
{
return NULL;
}
if (!$filter || !in_array($obj, $filter))
{
echo "ignore due to filter:$obj
";
return NULL;
}
//echo "Create:$obj
";
return new $obj($container, $pdf, $context);
}
}
?>