【发布时间】:2015-01-28 09:44:07
【问题描述】:
我使用 TCPDF 取得了巨大成功,但遇到了一些我似乎无法修复的问题。
这张图片显示了正在发生的事情。在文本上绘制了线条,并且对文本应用了删除线,我不想要其中任何一个。
这里是代码。我已经用 cell() 和 text() 试过了,得到了相同的结果。除了不需要的线条外,这一切正常。对这里发生的事情有任何想法吗?
TCPPDF 版本为 6.2.5
$pdf = new TCPDF('L', 'in', array($cardHeight,$cardWidth),TRUE,"UTF-8");
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->SetMargins(0, 0, 0);
$pdf->SetAutoPageBreak(FALSE, 0);
$pdf->AddPage();
$cardData = json_decode($this->getData());
$frontData = $cardData->front->fields;
foreach ($frontData as $key => $value) {
$alignment = strtoupper($value->align[0]);
$w = $value->w/$dpiCorrection;
$h = $value->h/$dpiCorrection;
$cmyk = $this->rgb2cmyk( $this->hex2RGB($value->color) );
$text = trim($value->text);
$pdf->SetFont($value->font, $value->weight, $value->size);
$pdf->SetTextColor((int)$cmyk['c'], (int)$cmyk['m'], (int)$cmyk['y'], (int)$cmyk['k']);
// $pdf->SetXY($value->x/$dpiCorrection, $value->y/$dpiCorrection);
// $pdf->Cell(
// $w, // width
// $h, // height
// $text, // text
// 0, // border
// 0, // ln - current postion after call
// $alignment, // L, C, R, or justify alignment
// 0, // fill 1 = painted, 0 = transparent
// '', // link
// 0, // font stretch mode
// 1, // 1 = ignore automatic minimum height value
// '', // cell vertical alignment, relative to specified Y value
// '' // text vertical alignment
// );
// $pdf->Cell(0,0,"Testing".$key);
$pdf->Text($value->x/$dpiCorrection, $value->y/$dpiCorrection, "testing ".$key);
}
$filename = storage_path() . '/test.pdf';
$pdf->output('test', 'D'); // 'D' force download, 'I' show inline
$headers = array(
'Content-Type' => 'application/pdf',
);
这是边框设置为 1 的输出。
【问题讨论】:
-
只是想注意
strikethrough也可能是底部边框并且文本溢出它, -
尝试
$pdf->Text($value->x/$dpiCorrection, $value->y/$dpiCorrection, "");会有什么结果?此外,请使用 TCPDF 的确切版本更新您的问题,因为即使是微小的修订也可能有截然不同的怪癖。 -
如果您将
1传递给边框参数,您的输出看起来会有所不同吗? -
@MonkeyZeus,您的建议会生成一个空白文档。我使用的是 TCPDF 版本 6.2.5。
-
@maja,我发布了一个边框 =1 的屏幕截图。