基于PHP与XML的PDF文档生成技术


reate_object( $parent, "line" );

$line->pc_set_linestyle( $line->attrs["LINETYPE"]);

$line->pc_set_width( $line->attrs["SIZE"] );

$line->pc_set_alignment( "center" );

if($line->attrs["SHOW"]==false){

$line->pc_set_linecolor( "white" );

}

$line->pc_set_margin( array( "top" => $line->attrs["TOP"], "bottom" => $line->attrs["BOTTOM"], "left" => 0, "right" => 0 ) );

}



function draw_text(&$parent,$text){

// code ignored...

}

function draw_table(&$parent,$table){

// code ignored...

}



function addhead(&$parent,$head){

for($i=0;$i< $head->n;$i++){

switch ($head->nodes[$i]->name){

case "LINE":draw_line($parent,$head->nodes[$i]);break;

case "TEXT":draw_text($parent,$head->nodes[$i]);break;

}

}

}

//..

?>

<?

// Create a PDF Document

$PDF = &pc_create_pdf( array( "Author" => "cyman", "Title" => "a report example" ) );

// Create an A4-format page

$Page1 = &pc_create_page( $PDF, $pageSet["PAGETYPE"]);

addhead($Page1,$head);

$PDF->pc_draw();

?>





6.总结

在几个月来的毕业设计过程中,虽然忙碌,却非常充实。通过对一个实际的课题的分析,研究,论证,实现。感觉收获颇多。目前,这套系统已投入使用,收到了非常满意的效果,可以很容易的做出美观实用的报表、单据等。但是,由于时间上的仓促以及自己水平的有限,这套系统仍有许多不足之处。其中最遗憾就是,没有能定义出一套对各种文档(包括报表、单据、手册等等)都通用的XML标记,并编制通用的程序将这个XML文档转化为PDF,就如同浏览器解析HTML一样。这样就不必为每一种文档都定义各自的XML标记并编写相对应的转换程序,可以大大提高工作效率。

虽然毕业设计已经结束,但是我将会今后的日子里继续这个课题的研究。
Copyright © 2008 chengduxinxi.com All Rights Reserved PHP编程开发 由朝夕网络维护