using print.css for pdf?

Re: [rez] using print.css for pdf?

By Jason - August 19, 2011

Hi,

the createPDF plugin will render the page as a PDF exactly how it would look if viewed through a browser. If you need to load a different CSS file when creating the PDF you have a couple of options. You could create a separate template that is used for the PDF. Another option would be to pass a variable to in your URL showing that this would be a PDF. For example:

www.mysite.com/detailPage.php?num=6&pdf=1

You can then use the presence of this pdf variable to determine which css file to load:

<?php if (@$_REQUEST['pdf'] ==1): ?>
<link rel="stylesheet" type="text/css" media="screen" href="print.css" />
<?php else: ?>
<link rel="stylesheet" type="text/css" media="screen" href="screen.css" />
<?php endif?>

Hope this helps

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/