简体   繁体   English

DOMPDF:表格右对齐

[英]DOMPDF: Table align right

I'm trying to make a table float right in DOMPDF. 我正试图让一个表在DOMPDF中浮动。 I'm using the newest version DOMPDF 0.6.0 beta2. 我使用的是最新版本的DOMPDF 0.6.0 beta2。 In the dompdf_config.inc.php I've set DOMPDF_ENABLE_CSS_FLOAT to true. 在dompdf_config.inc.php中,我将DOMPDF_ENABLE_CSS_FLOAT设置为true。 Here is my code template: 这是我的代码模板:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>Printed document</title>
</head>
<body>

    <table cellspacing="0" cellpadding="0" style="float:right;" border="1">
        <tr>
            <td style="padding-right:20px;">Property</td>
            <td>Value</td>
        </tr>
        <tr>
            <td style="padding-right:20px;">Property</td>
            <td>Value</td>
        </tr>
    </table>

</body>
</html>

Here is the resulting PDF: http://uploads.dennismadsen.com/test.pdf 以下是生成的PDF: http//uploads.dennismadsen.com/test.pdf

How can I align the table in right? 如何对齐桌子? Further, why is the padding-right not working to make space between the columns? 此外,为什么填充权不能在列之间留出空间?

尝试使用<table cellspacing="0" cellpadding="0" align="right" border="1">而不是style属性。

DOMPDF 0.6.0 beta 2 (even with DOMPDF_ENABLE_CSS_FLOAT set to true) does not have full float support. DOMPDF 0.6.0 beta 2(即使DOMPDF_ENABLE_CSS_FLOAT设置为true)也没有完全浮点支持。 Most of the work is preliminary and not recommended for production use, and you can see why. 大多数工作都是初步的,不建议用于生产,你可以看到原因。 Unfortunately, the layout you're attempting to produce will be difficult at best until float support is fully implemented. 不幸的是,在完全实现浮动支持之前,您尝试生成的布局最多是困难的。

As for the padding problem, this appears to be a bug. 至于填充问题,这似乎是一个错误。 If you remove the cellspacing and cellpadding values the padding will be applied correctly. 如果删除cellspacing和cellpadding值,将正确应用填充。 If you want to apply 0 padding to your cells you can do this through a global style, the element-specific style will correctly override it. 如果要对单元格应用0填充,可以通过全局样式执行此操作,特定于元素的样式将正确覆盖它。

I'm having the same problem. 我遇到了同样的问题。

I just had an Idea to specify the padding-right:; 我只是想要指定padding-right:; independently of the rest of the padding...but I entered much higher number. 独立于填充的其余部分...但我进入了更高的数字。

IE: table td {padding:3px 5px 3px 5px; padding-right:10px;} IE: table td {padding:3px 5px 3px 5px; padding-right:10px;} table td {padding:3px 5px 3px 5px; padding-right:10px;}
Somehow...It seems to work when I generate my test PDF... 不知怎的......当我生成我的测试PDF时似乎工作...

If I enter the same padding; 如果我输入相同的填充; however: 然而:
IE: table td {padding:3px 5px 3px 5px; padding-right:5px;} IE: table td {padding:3px 5px 3px 5px; padding-right:5px;} table td {padding:3px 5px 3px 5px; padding-right:5px;}
Then...it does not work... 然后......它不起作用......

I tried entering all the values independently as well: 我也尝试独立输入所有值:
IE: {padding-top:3px; padding-bottom:3px; padding-left:5px; padding-right:5px;} IE: {padding-top:3px; padding-bottom:3px; padding-left:5px; padding-right:5px;} {padding-top:3px; padding-bottom:3px; padding-left:5px; padding-right:5px;}
...and....NOTHING. ...没事了。

It seems that you must enter a higher value...perhaps DOUBLE what you want. 看来你必须输入更高的价值......也许你要的是双倍的。 When I enter other values...15px 25px, etc. The padding get's larger. 当我输入其他值... 15px 25px等时,填充变得更大。

Hope that helps. 希望有所帮助。

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

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