Fixing Page breaks in PDF created from a list page

Hi all,

Any idea how I can keep the PDF that’s created from a list page from having page breaks in the middle of some of the images and lines?

Here’s the link in question:

http://www.elleschorrphotography.com/exhibitions.php


*** Click the link to create the PDF and scroll down to the page breaks.

And here’s the code for the list viewer:
<table width="90%" border="0" align="center" cellpadding="10">
<?php foreach ($exhibitionsRecords as $record): ?>
<tr>
<td width="16%" valign="middle" class="Medium-Text">
<div align="center"><br />
<?php foreach ($record['image'] as $upload): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php endforeach ?>
</div>
</td>
<td width="28%" valign="top" class="Medium-Text">
<div align="left"><br /><?php echo $record['exhibition_dates'] ?><br>
</div>
</td>
<td width="56%" valign="top" >
<hr align="center" width="300" color="#f00" />
<div align="left"><span class="X-Large-Text"><?php echo $record['title'] ?></span><br>
<span class="Medium-Text"><?php echo $record['description'] ?></span><br />
<?php foreach ($record['publicity'] as $upload): ?>
<a class="publicity" href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?></a><br />
<?php endforeach ?>
<?php if ($record['publicity_url']): ?><?php if (!preg_match("/^http:\/\//", $record['publicity_url'])) {
$record['publicity_url'] = "http://" . $record['publicity_url']; }
?>
<a class="publicity" href="<?php echo $record['publicity_url'] ?>"><?php echo $record['publicity_link_text'] ?></a>
<?php endif ?>
</div>
</td>
</tr>
<?php endforeach ?>
</table>


Thanks again,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Fixing Page breaks in PDF created from a list page

By robin - March 25, 2011

Hi Jerry,

The pdf creator generally respects css print properties. The following code might do the trick. It tells the browser not to page break in the middle of a table row.

This goes in the HTML head
<style>
tr {page-break-inside:avoid}
</style>


Please let me know if you have any further problem.

Robin
Robin
Programmer
interactivetools.com

Re: [gkornbluth] Fixing Page breaks in PDF created from a list page

By gkornbluth - March 25, 2011 - edited: March 25, 2011

Hi Robin,

Sorry, but that didn't work. I've even tried style="page-break-inside:avoid" in the <tr> tag.

I found this http://www.w3schools.com/CSS/pr_print_pagebi.asp which says that opera is the only browser that will support break-inside:avoid.

Do you have any other idea I might try?

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Fixing Page breaks in PDF created from a list page

By robin - March 28, 2011

Hey Jerry,

Too bad that didn't work for you. I've been talking to Damon about this problem. Tables tend to page break badly. In the past people have either switched from table layout which works a lot better for print.

Another thing that could work is to break the table or use the css "page-break-after:always" after a certian number of rows. That is tricky with variable length content however.

Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Fixing Page breaks in PDF created from a list page

Thanks Robin,

I agree about the variable length content issue.

I'll play around with a CSS approach to replace the table and see if that helps any.

Any suggestions appreciated.

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php