【发布时间】:2012-10-25 12:55:11
【问题描述】:
我有一个从数据库 blob 构建多页 pdf 的脚本。这个 pdf 可以工作并输出良好的电流,但我需要在每页的左侧添加一行垂直的文本。我已经设法让它适用于一些 pdf,但对于一些我得到一个损坏的文件错误。有没有人有不同的添加垂直文本的方法我可以尝试使用 fpdf/fpdi。
这是我目前所拥有的:
function buildBSIPDF($filename){
global $supplier;
$pdf = new FPDI();
$i = 1;
$pagecount = $pdf->setSourceFile($filename);
//create text to append
$sideline = "Some text here";
while($i <= $pagecount){
//$pdf->setSourceFile($filename);
// import page 1
$tplIdx = $pdf->importPage($i);
//use the imported page and place it at point 0,0; calculate width and height
//automaticallay and ajust the page size to the size of the imported page
//$s = $pdf->getTemplatesize($tplidx);
$pdf->AddPage();
$pdf->useTemplate($tplIdx);
// now write some text above the imported page
$pdf->SetFont('Arial', '', '12');
$pdf->SetTextColor(0,0,0);
//set position in pdf document
$pdf->SetXY(20, 20);
//first parameter defines the line height
$pdf->RotatedText(5,250,$sideline,90);
$i++;
}
$pdf->Output($filename, 'F');
}
【问题讨论】: