Page 1 of 1
Need help with page formatting for printer.
Posted: Sat Feb 17, 2007 7:33 am
by Jack.Straw
Hi. I've put together an application for work that reads excel files and then displays them as html forms. Users can then edit the form and click a 'print' button which loads a printable table displaying formatted results. This all works quite well, except.. page breaks.
The table on the 'print' page will have an unpredictable number of rows, and each row has an unpredictable number of carriage returns. How could i get my program to close the table at the end of page 1 and start again on page 2? The table is created within a loop. Is there any way to tell where the end of a printable page is so that i can make this thing work?
Posted: Sat Feb 17, 2007 8:51 am
by feyd
Generate a PDF, it's the only way to reliably control it.
Posted: Sat Feb 17, 2007 11:28 am
by Jack.Straw
uggg.. ok, i'll look into that. Thanks!
-Jack
Posted: Sat Feb 17, 2007 11:59 am
by Bill H
I noticed you didn't suggest using CSS "paged media" output.
Is there ever going to be a browser that supports it, do you think?
Posted: Sat Feb 17, 2007 12:33 pm
by feyd
Bill H wrote:I noticed you didn't suggest using CSS "paged media" output.
Is there ever going to be a browser that supports it, do you think?
Probably at some point, but until the majority support it, I can't very easily do so.
Posted: Sat Feb 17, 2007 2:10 pm
by Bill H
Oh, I was not trying to imply that you should have suggested it.
Au contraire, I was glad you didn't.
Some time ago someone led me into that pitfall and I fiddled with it for several days until it was finally pointed out to me that not one single browser in the universe (at that time) supported it. I was a bit annoyed. I went the PDF route, as I recall.
But it will be a nice feature when it does get support, as it is clean and straightforward.
Does any browser support it at this point?
Posted: Sat Feb 17, 2007 2:57 pm
by Kieran Huggins
Check for support in Opera - they're usually pretty anal about supporting every standard.
Posted: Sat Feb 17, 2007 4:44 pm
by Jack.Straw
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
ok, i've done some research on creating pdf files with PHP. That's great!
However...
I face the same problem with the pdf file as I do with regular html. How do i know when my table has reached the end of the page? To be clear on what my program is doing, please see this example:
Code: Select all
<table>
<tr>
<?PHP
for ($i=0; $i<count($rows); $i++) {
if (END OF PAGE) {
echo "</tr></table>";
StartNewPage();
echo "<table><tr>";
}
echo "<td>$rows[$i]</td>";
}
?>
</tr>
</table>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Sat Feb 17, 2007 9:16 pm
by Kieran Huggins
remember: you're making a PDF, not HTML - you should be placing individual elements at x & y co-ordinates relative to a corner of the page.
So a table would become nothing but a series of "cells" of content.
Posted: Sat Feb 17, 2007 9:55 pm
by RobertGonzalez
Is there a way to use the page-break-inside: avoid; CSS directive?
Posted: Sun Feb 18, 2007 10:05 am
by Jack.Straw
Kieran Huggins wrote:remember: you're making a PDF, not HTML - you should be placing individual elements at x & y co-ordinates relative to a corner of the page.
So a table would become nothing but a series of "cells" of content.
I understand, but the root of the problem to begin with is that i never know exactly how much information going to be in any given field (it's mostly user input). Placing the first row would be no problem, but where do i start the 2nd? How do i know when it's time to start a new page? I guess i could count the characters in each string.. hmm
Posted: Sun Feb 18, 2007 10:14 am
by feyd
ezpdf makes report generation pretty simple.
Posted: Sun Feb 18, 2007 12:13 pm
by Jack.Straw
ezpdf worked great! thanks so much!!