我正在使用带有DomPDF的Codeigniter,它通常运行良好,但有一种情况是它插入空白页面并剪切后面的内容。我注意到,如果我在包含连续<i>
标记的一大块文本中包含<b>
或<br />
个标记,就会发生这种情况。例如,采用以下结构:
<p>some text <i>some text<br /><br />some text ... </i></p>
最终会插入空白页并剪切内容。
输出内容的代码是:
...
<div style="page-break-before:always;"></div>
<?php foreach ($entries as $entry) { ?>
<p><?php echo nl2br(str_replace(" ", " ", $entry['description'])); ?></p>
<?php } ?>
<p><?php echo $copyrightmessage ?></p>
<div style="page-break-before:always;width:100%;text-align:center;">
<div style="height:100px;"></div>
<img src="writerbig.png" />
<br />
</div>
...
以下是重现问题的示例HTML:
To better understand why this course of action was necessary,
A'th'n learned why<br /> <br /> it was the responsibility, shame of each of the incarnations for ridding this
world of<br /> <br /> this threat.<br /> <br /> H'br'a, spoken
through A'yd'a, explained the CHTHONIAN collective and why, since<br /> <br /> A'yd'a through T'li'a, H'br'a, now, A'th'n it had to come to this point.<br /> <br /> <br />
<i>Since her initial landfall, every time that the Primae had released a life force<br /> <br /> from a body she
killed, this being the only logical solution to correct the crisis,<br /> <br /> the spirit had nowhere to go. <br />
<br /> It hung in the ether seeking spiritual release. Never finding any, the spirits soon <br /> <br /> learned that
joining together made them capable of<br /> <br /> creating entities that could exist, again, in the living world,
albeit as Sapen<br /> <br /> mockeries. <br /> <br /> Learning swiftly, the collected spirits came to the
realization that not<br /> <br /> only could they exist on the living plane they could alter it.<br /> <br />
It was this "awakening" that started their raiding, terrorizing,
destroying all<br /> <br /> living beings they encountered.<br /> <br />
The end result of their intermingling was to, first, confuse, next,
annihilate<br /> <br /> the outer husks of the tortured to absorb them into their collective existence.<br /> <br
/> <br /> In time, the first few spirits realized they were capable of
manipulation,<br /> <br /> allowing them to become very adept at their methods with the one goal being
total<br /> <br /> domination of all species, races.<br /> <br /> Keeping their combined numbers small enabled
them to become the most powerful psychic <br /> <br /> entities ever created.<br /> <br />
The more powerful, the collective became the more notice the
Primae took of them.<br /> <br /> Within a few life cycles, the
Primae realized it was her responsibility to end<br /> <br /> this threat. However, the collective was always one
step ahead, they knew that if the<br /> <br /> Primae caught them, she would release them back, unwillingly,
into the spirit world<br /> <br /> where they would soon disperse into eternity.<br /> <br />
This evasion continued until H'br'a, who was a greater Primae then
ever before,<br /> <br /> since she was a hybrid of two species, Sapen and Floar. It was this species melding<br
/> <br /> that prevented the collective from manipulating her mind.<br /> <br />
H'br'a would have succeeded, in totally eradicating the collective
that all the<br /> <br /> previous incarnations had attempted, except two had been on a raid, when she
arrived.<br /> <br /> Before H'br'a had the opportunity to complete the spiritual release, she had<br /> <br />
received her next to last tattoo that triggered her action to seek out her successor.<br /> <br /> All following
actions lead to her capture by the Levians until she was rescued<br /> <br /> and reborn as A'th'n.<br /> <br />
Now it was up to A'th'n, a further enhanced incarnation, who,
because of her<br /> <br /> being an older Primae incarnation and her physical differences, made
her immune to the<br /> <br /> CHTHONIAN collective influence.<br /> <br /> Her untried plan with F'lisa,
hopefully, would be the solution.</i><br /><br /><br />
每个条目都包含纯文本,但可选的是<i>
和<b>
个标记(正确嵌套)。
如果我从条目中删除<i>
标记,则格式完美。
知道怎么解决这个问题吗?
答案 0 :(得分:2)
我最终在打印PDF文件之前编写了一个脚本来解嵌HTML。
我做了类似的事情:
查找<br />
个代码之间的所有<i></i>
代码,并将其替换为</i><br /><i>
我知道如果可以使用嵌套HTML标记的任何组合,这种方法将无法很好地扩展,但在我的情况下,标记仅限于<br>
,<i>
和<b>
希望这会对某人有所帮助
答案 1 :(得分:0)
嵌套标签和DomPDF不是好朋友。您可以尝试使用和字体,如果这不起作用,请尝试用span替换它们。
也许问题在于某些分页符。如果标签打开时页面中断,则会破坏整个PDF。