简体   繁体   中英

DOMPDF: Table align right

I'm trying to make a table float right in DOMPDF. I'm using the newest version DOMPDF 0.6.0 beta2. In the dompdf_config.inc.php I've set DOMPDF_ENABLE_CSS_FLOAT to 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

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. 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. 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.

I'm having the same problem.

I just had an Idea to specify the 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;} table td {padding:3px 5px 3px 5px; padding-right:10px;}
Somehow...It seems to work when I generate my test PDF...

If I enter the same padding; however:
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;} {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.

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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