dhrm
dhrm

Reputation: 14934

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?

Upvotes: 2

Views: 11550

Answers (3)

vitaly87
vitaly87

Reputation: 306

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

Upvotes: 0

BrianS
BrianS

Reputation: 13914

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.

Upvotes: 3

user657496
user657496

Reputation:

Try using <table cellspacing="0" cellpadding="0" align="right" border="1"> instead of the style attribute.

Upvotes: 5

Related Questions