简体   繁体   English

来自PHP的输出=正常,来自DOMPDF的输出=错误。 (显示)

[英]output from PHP = ok, from DOMPDF = wrong. (display)

This output run fine in HTML / PHP: 此输出在HTML / PHP中运行良好:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head>
<title>(PAbi)</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<style type="text/css">html,body{margin:0;padding:0;background:#000;color:#fff;font-family:helvetica;}
.pie{position:fixed;width:100%;bottom:0;color:#000;background:#fff9f2;font-size:6.5pt;text-align:center;border-top:1px dashed #aa0000;}
#indice{width:430px;margin:auto;}
#indice dt{float:left;width:300px;overflow:hidden;white-space:nowrap;}
#indice dd{margin:0;float:left;width:100px;overflow:hidden;}
#indice dt span:after{content:".....................................................";}
</style></head>
<body><div id="cosmos"><br />
<h1 class="marin">index</h1>
<ul id="indice">
<dt><span>Índice</span></dt><dd>2</dd>
<dt><span>intro</span></dt><dd>3</dd>
<dt><span>functions</span></dt><dd>4</dd>
</ul></div>
<div class="pie">Aliens is here</div>
</body></html>

just as you can see, I need create the index page, then I need this "doits", I get this code from: 如您所见,我需要创建索引页面,然后需要这个“ doits”,可以从以下代码获取此代码:

CSS Justify text, fill space with dots CSS对齐文本,用点填充空间

But when I export to PDF with DOMPDF, the display go bad... 但是当我使用DOMPDF导出到PDF时,显示效果变差了。。。

Thanks by any help to I can create the page "index" using doits to numbers of pages?, thanks! 感谢您的帮助,我可以使用对页面数的点数来创建页面“索引”吗?谢谢!

Regards friends. 问候朋友。

Using this code I can "create" my "page index" using: 使用此代码,我可以使用以下方法“创建”我的“页面索引”:

  • XHTML XHTML
  • DOMPDF DOMPDF
  • index info with "doits" to show page number 带有“ doits”的索引信息以显示页码

Problem is when you used from css [TAG:after{content:"...your string here...";}] DOMPDF forever put a newline and then display of "page index" is wrong in the document PDF. 问题是,当您从css [TAG:after {content:“ ...您的字符串在这里...”;}]中使用DOMPDF时,它会永远放一个换行符,然后在文档PDF中显示“页面索引”是错误的。

maybe any person want used this option... 也许任何人都想使用此选项...

<?php
// I put excesive doits only by do test xD
    $puntos = str_repeat('.', 999);

    echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head><title>(PAbi)</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<style type="text/css">
table{width:650px;border-spacing:0.5em;}
#indice1 td{overflow:hidden;max-width:400px;border-radius:2em;padding:0.3em;}
#indice1 span:after{content:"'.$puntos.'";}
.numpa{text-align:center;width:20px;background:#d3dbfa;border:1px solid #000;}
.info{width:205px;background:#d1f6a5;border:1px solid #000;}
</style></head><body>
<table id="indice1"><tr>
<td class="info">ÍNDICE</td>
<td class="puntos"><span></span></td>
<td class="numpa">2</td></tr><tr>
<td class="info">Introducción</td>
<td class="puntos"><span></span></td>
<td class="numpa">3</td></tr><tr>
<td class="info">Características del servicio</td>
<td class="puntos"><span></span></td>
<td class="numpa">4</td>
</tr></table></body></html>';
?>

Unfortunately Dompdf (current release being v0.8.0) is unable to handle that particular styling. 不幸的是,Dompdf(当前版本为v0.8.0)无法处理该特定样式。 The main issue is that Dompdf does not correctly reflow floats at the end of the line. 主要问题是Dompdf在该行的末尾没有正确地重排浮动。 But even if you force it using something like #indice dd + dt { clear: both; } 但是,即使您使用#indice dd + dt { clear: both; } #indice dd + dt { clear: both; } Dompdf does not appropriately clear the float and continues writing floats the additional floats to the same line. #indice dd + dt { clear: both; } Dompdf无法正确清除浮点数,而是继续将浮点数和其他浮点数写入同一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM