PDA

View Full Version : What is best way to print multiple pages long table?



squizzz
19th February 2012, 17:07
Hi,

I need to create a raport that is basically long table of items, spanning across multiple pages. So far I created simple html document using QTextEdit/QTextDocument ability to store some rich text elements like tables, and then simply use print method of QTextEdit\QPrinter to print it.

The problem is, however, printing tables like this kind of fails on page breaks - row is often split on separate pages (sometimes with additional glitches) and this is not what I want.
My question is - is there a way to ensure that table rows are always printed entirely on single page, i.e if there is not enugh space left on the current page, then draw new row on the next page, instead of slicing it in half?

If not, do you guys have better, tried ways to print this kind of document (multiple pages long table) in QT correctly?

Ps. I'm using Qt 4.7.4


Regards,
Jan

Lykurg
20th February 2012, 08:45
You can always use QPainter with a QPrinter directly. So you can draw the table yourself and check if enough space is left on the page. It is more complicated, but the only solution I can think of right now.

squizzz
20th February 2012, 21:34
Thanks for the answer. Yes, this is what I resulted to do in the end. Hoped that there was some way to avoid implementing document layout by hand, I quess you can't have everything, even with Qt :)

Wonder if printing from webkit paginates tables correctly..

Regards,
Jan