| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Andreas Pakulat wrote:
> For Qt4 I think the proper way would be to provide your own
> QAbstractTextDocumentLayout class and eventually with a new QTextObject
> subclass. You might also need your own QTextDocument if you want to have
> something like insert page break after the current cursor.
That's a lot of work :-(
Yesterday I wrote some lines. Now I just produce QTextDocument for each
string. Rendering of these documents on QPictures for the preview widget
causes no problem. Exporting to pdf works also fine with this code
(documents is a QList with QTextDocumens):
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
for ( int i=0; i<documents.size(); i++)
documents.at(i)->print(&printer);
All the documents are exported to the same pdf-file. On the other side,
"normal" printing with the code above fires up several print jobs. I'll
rewrite/adjust QTextDocument::print for my purposes, as Volker suggested.
It would be very very nice if such a small preview widget would be included
in Qt (like QAssistent). So we all don't need to do same work again and
again...
Alexander.
--
[ signature omitted ]
Alexander Semke did a mistake: > I didn't work much with Scribus... It's called Scribe of course, not Scribus :-) Alexander -- [ signature omitted ]
(picking up a rather old mail) On Monday 31 July 2006 13:37, Alexander Semke wrote: > Hello, > > I'm looking for a possibility to initiate a new page within QTextDocument. > At the moment I produce one big html-string and call > QTextDocument::setHtml(). Now I need to break the pages at some points but > I don't see any createNewPage()-function or something like that in > QTextDocument. > > The first idea to overcome this problem was to create multiple > html-strings(one for each page) and to do the following steps: > > 1. render each of these strings to a temporary QTextDocument > 2. look for the number of lines written on the page > 3. determine the number of lines needed to complete the page > 4. append the needed number of <br>'s to the string > > At the end I would concatenate all strings to one big string and set it in > the main QTextDocument. In this case those <br>'s would guarantee the > proper appearance. > I don't know exactly how to implement the second and the third steps, but > somehow that should be possible with the help of QTextCursor and the number > of paragraphs. I didn't implement it yet, but I'm pretty sure this > procedure will be very slow (rendering of a 70-page document in the > "hand-made" preview-widget took already without page breaking 10-15 > seconds). > Did somebody do something similar? Are there any better ways to do page > breaking? I didn't work much with Scribus, so I hope somebody more > experienced can give me some advises. I have good news you: Tomorrow's 4.2 snapshot will have support for the page-break-before/page-break-after CSS properties on tables and paragraphs as well as the ability to specify enforced page breaks as properties on a QTextBlockFormat or a QTextFrameFormat. Simon
Attachment:
Attachment:
pgpMowVRucVxQ.pgp
Description: PGP signature