I am using DOMPDF (v 0.5.2) to convert an html page to a pdf file.
The pdf file appears after the PHP script has run (as expected), but no styles are applied to any of the content. As far as I can find, the float property does not work with DOMPDF, so I have to do some work to get around that, but not even the font styles are being applied.
I have tried all three methods of including styles:
attaching a style sheet,
<link href="styles.css" rel="stylesheet" type="text/css">
writing styles in the header,
<style>...</style>
and inline styles.
<div class="..." style="...">
The php file to create the pdf looks like this...
<?php
ob_start();
?>
<html>
<head>
<link href="flhaha.css" rel="stylesheet" type="text/css">
</head>
<body>
... content (divs, etc)
</body>
</html>
<?php
require_once("../../scripts/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html(ob_get_clean());
$dompdf->render();
$dompdf->stream('test.pdf');
?>
There is an image within the content that loads fine and is displayed properly when the pdf opens, but still no styles.
Thanks in advance!
Edit #1: The tags above were meant to be "style", not "styles". Have fixed the typo.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…