Php 为什么DomPDF插入空白页并剪切内容

Php 为什么DomPDF插入空白页并剪切内容,php,codeigniter,dompdf,Php,Codeigniter,Dompdf,我在DomPDF中使用Codeigniter,它通常工作得很好,但有一种情况是它插入空白页面并剪切后面的内容。我注意到,在包含连续的标记的文本块中有或标记时,就会发生这种情况。例如,以该结构为例: <p>some text <i>some text<br /><br />some text ... </i></p> 一些文本一些文本一些文本 最后插入空白页并剪切内容 输出内容的代码是: ... <div style

我在DomPDF中使用Codeigniter,它通常工作得很好,但有一种情况是它插入空白页面并剪切后面的内容。我注意到,在包含连续的

标记的文本块中有
标记时,就会发生这种情况。例如,以该结构为例:

<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("  ", "&nbsp;&nbsp;", $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 /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<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 /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; It was this "awakening" that started their raiding, terrorizing, 
destroying all<br /> <br /> living beings they encountered.<br /> <br /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The more powerful, the collective became the more notice the 
Primae took of them.<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Now it was up to A'th'n, a further enhanced incarnation, who, 
because of&nbsp;&nbsp;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 />
为了更好地理解为什么需要采取这种行动,
A'th'n明白了为什么这是每一个化身的责任和羞耻,为了摆脱这一切
这个威胁的世界。


通过A'yd'A,解释了赫顿集体,以及为什么A'yd'A通过T'li'A,H'br'A,现在,它必须走到这一点。



自从她首次登陆以来,每次Primae从一具尸体上释放出一种生命力时,她 被杀,这是纠正危机的唯一合乎逻辑的解决方案,

精神无处可去

它挂在以太中寻求精神上的解脱。再也找不到了,精灵们很快就明白了这一点 结合在一起使他们能够创造出能够再次存在于生活世界中的实体, 尽管是一种讽刺

由于学得很快,收集的烈性酒来到了 意识到不是只有他们才能存在于生命平面上,他们可以改变它。

正是这种“觉醒”开始了他们的袭击、恐吓, 摧毁他们遇到的所有生物。

他们混在一起的最终结果是,首先,混淆,其次, 消灭受折磨者的外壳,将其吸收到他们的集体存在中。


随着时间的推移,最初的几个灵魂意识到他们有能力 操纵,

允许他们非常熟练地掌握自己的方法,目标是 所有物种、种族的总统治权。

他们将成为有史以来最强大的心灵实体。


权力越大,集体越受关注 Primae拿走了它们。

在几个生命周期内 Primae意识到结束这一威胁是她的责任。然而,集体总是一个 向前一步,他们知道如果首席抓住他们,她会不情愿地把他们放回去, 进入精神世界

在那里他们很快就会分散到永恒中。

这种逃避一直持续到赫布拉,他当时是一个更大的首席执行官 以前,

因为她是两个物种的杂交种,Sapen和Floar。正是这个物种融合了

这阻止了集体操纵她的思想。

H'br'a会成功地彻底根除集体暴力 所有前世的人都曾尝试过,只有两个在袭击中,当她 到达。

在H'br'a有机会完成灵性释放之前,她已经

收到了她最后一个纹身,触发了她寻找继任者的行动。

这些行动导致她被列维人俘虏,直到她获救并重生为一名“th”n.

现在是A'th'n,一个进一步强化的化身, 因为她

是一个更老的原始化身和她的身体差异 她对荷兰的集体影响免疫。


, 希望这就是解决方案。



每个条目都包含纯文本,但某些
标记(正确嵌套)除外。 如果我从条目中删除
标记,它的格式会非常完美


你知道怎么解决这个问题吗?

嵌套标签和DomPDF不是好朋友。您可以尝试使用和字体,如果不起作用,请尝试使用跨距替换它们


也许问题出在某些分页符上。如果标签打开时页面断开,它将断开整个PDF。

在打印PDF文件之前,我编写了一个脚本来取消嵌套HTML

我做了这样的事情:

找到
标记之间的所有

标记,并将其替换为

我知道如果嵌套HTML标记的任何组合都是可能的,那么这种方法将无法很好地扩展,但在我的例子中,标记仅限于


希望这会对某些人有所帮助

这不一定是真的。dompdf能够很好地处理嵌套标记。有些问题可能是有问题的,但我不认为“嵌套标签”是这里的问题。它有助于查看HTML,而不是生成HTML的PHP。我无法用您发布的简单代码复制此问题。另外,您使用的是哪个版本的dompdf?嗨@BrianS,我已经编辑了这个问题,添加了实际中断的HTML。请让我知道你是否可以复制这个问题。我使用的是最新版本(刚从Github下载),我不确定问题出在哪里,但dompdf在这篇文章中肯定有问题。可能是celements和paging的问题。我现在没有一个好的解决方案,除了将每一行隔离到它自己的DIV元素中。