secondman
secondman

Reputation: 3277

No Inline CSS in DOMPDF

I'm using DOMPDF to build out a download report of database entries for a shopping cart.

Not sure what code to put in here, it's a very typical html page with some foreach loops to display the content, and it creates the pdf just fine, but none of the css from the file is rendered as css, it gets printed as text at the top of the document.

The CSS is inline in the head of the document as any normal inline css would be.

$export_pdf ="<html><head>";
$export_pdf .="<meta http-equiv='Content-Type' 
                 content='text/html; charset=utf-8' />";
$export_pdf .="<style type='text/css'>
     .list {
     border-collapse: collapse;
     width: 100%;
     border-top: 1px solid #DDDDDD;
     border-left: 1px solid #DDDDDD;    
     font-family: Arial, Helvetica, sans-serif;
     font-size: 12px;
}
.list td { border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; }
.list thead td { background-color: #E5E5E5; padding: 3px; font-weight: bold; }
.list tbody a { text-decoration: none; }
.list tbody td { vertical-align: middle; padding: 3px; }
.list .left { text-align: left; padding: 7px; }
.list .right { text-align: right; padding: 7px; }
table .interior,
table .interior td { border: none !important; }
table .interior tr { border-bottom: #DDD 1px solid !important; }
.list tbody .interior thead td { background: #efefef !important; }
</style>";

Then just a basic table etc.

I can't find anyone else having this issue with inline css. I've seen some posts where people have troubles getting linked styles to work, but this is simple inline css, why is it being interpreted as text instead of css?

Thanks.

-Vince

Upvotes: 1

Views: 2664

Answers (1)

Fabien M&#233;nager
Fabien M&#233;nager

Reputation: 140195

As weird as it appears, it is due to the simple quotes in the <meta> tag. Replace them by escaped double quotes and it will work. Could you report this issue in the issue tracker please ?

Upvotes: 3

Related Questions