【发布时间】:2018-04-09 08:56:10
【问题描述】:
我在使用 TCPDF 生成 PDF 时遇到问题。要生成 pdf,我使用 writeHTML 函数。
问题是我的 PDF 中的某些文本随机显示。或者它的某些部分消失了。 这是我的 PDF 的样子:
在表格下方应该可以看到更多的文字。我的这个 PDF 的 HTML:
<br/><br/>
<table cellpadding="5" width="670">
<tbody>
<tr>
<td width="100">Data</td>
<td width="100">Typ</td>
<td width="370">Opis - Items</td>
<td width="100">Kwota - Amount</td>
</tr>
<?php if(!empty($this->finances)) : ?>
<?php foreach($this->finances as $finance) :?>
<?php if($finance['value'] != 0) : ?>
<tr>
<td width="100"><?= $finance['date']->toString('yyyy-MM-dd'); ?></td>
<td width="100"><?= ($finance['type'] == 'invoice') ? 'Fv nr '. $finance['invoice_no'] : 'Płatność - Paid'; ?></td>
<td width="370"><?= $finance['description']; ?></td>
<td style="text-align: right;" width="100"><?= $finance['value_sign'].$finance['value']; ?> PLN</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<tr>
<td colspan="3" style="text-align: right; font-weight: bold;" width="570">Saldo:</td>
<td style="text-align: right;" width="100"><?= sprintf('%s%.2f', $this->balance['sign'], $this->balance['balance']); ?> PLN</td>
</tr>
<?php endif ?>
</tbody>
</table>
<div style="font-size: 20pt;">Information – Informacje</div>
<p>(*) The sign “ – “ is put behind an amount invoiced by the School ; the sign “ +” is put behind an amount received by the School or a reduction calculated in accordance with School rules. When appearing, the line “bilans otwarcia” indicates the balance at the end of previous preschool year on 30.06.2017. Please kindly be informed that starting 15th October 2017, the School is obliged to apply legal interest penalty on delayed payment.</p>
<p>(**) Znak “ – “ pojawi się przed kwotami fakturowanymi przez Szkołę ; znak „ + „ pojawi się przed wpłatami otrzymanymi od państwa lub przed zniżkami kalkulowanymi zgodnie z regułami Szkoły. Kiedy jest pokazana pozycja „bilans otwarcia” oznacza to saldo na koniec zeszlego roku szkolnego tj. 30.06.2017. Uprzejmie informujemy że od 15-ego Pażdziernika 2017, Szkoła jest zobowiązana do stosowania ustawowych odsetek za opóżnione płatności. </p>
<p>(***) Le signe „ – „ apparait devant les montants facturés par l’Ecole ; le signe « + » apparaît devant les montants reçus par l’Ecole ou devant une reduction calculée selon le règlement de l’Ecole Quand elle apparait, la ligne « bilans otwarcia » indique le solde à la fin de l’année scolaire précédente, au 30.06.2017. Depuis le 15 Octobre 2017, la Maternelle est amenée à appliquer les intérêts de retard légaux sur le paiement des frais de scolarité.</p>
这是生成PDF的代码:
$this->SetFont('times', '', 11, true);
$this->setPrintHeader(false);
$this->SetMargins(10, 10, 10);
$this->AddPage('P');
$this->view->balance = array('paid' => $paid, 'to_pay' => $to_pay, 'balance' => $balance, 'sign' => ($balance <= 0) ? '' : '+');
$this->view->finances = $finances;
$this->view->child = $child;
if(!empty($child['GroupChild']) && !empty($child['GroupChild'][0]['group_id'])) {
$group = Doctrine::getTable('Group')->findOneBy('group_id', $child['GroupChild'][0]['group_id']);
if($group && strtolower($group->name) != 'outgoing'){
$this->view->group = $group->name;
} else $this->view->group = '';
} else $this->view->group = '';
$this->view->iban = $iban;
$this->view->now = new Zend_Date();
$html = $this->render('balance', 'html');
$this->writeHTML($html);
有什么快速的方法可以在不手动生成 PDF 的情况下修复此问题?我使用 Zend Framework 1.12 和生成 PDF 继承自 TCPDF 的类。
前段时间我有类似的问题,但它没有解决: Text disappeared in table in generated pfd by tcpdf
【问题讨论】:
-
line-height: 1pt;? -
我添加它是为了测试它改变了什么。没有它,文本也不会显示。
-
我注意到如果结束标记前有空格,文本会消失,例如。你已经解决了这个问题吗?你会怎么写?