Unsolved QPdfwriter: how to switch to a new page when first page is completed?
-
Title is clear as question: starting from a txt file longer than a single page, I'd like to complete my file in a second page when first is done.
How can I use NewPage() in order to understand when first page is completed? -
@alsa From docs:
"The newPage() method can be used to create several pages."http://doc.qt.io/qt-5/qpdfwriter.html#details
So, after you reach end of page you call the method to initiate next page.
-
@artwaw said in QPdfwriter: how to switch to a new page when first page is completed?:
@alsa From docs:
"The newPage() method can be used to create several pages."http://doc.qt.io/qt-5/qpdfwriter.html#details
So, after you reach end of page you call the method to initiate next page.
How can I know when end of page has been reached?
-
@alsa That is more complicated and depends on for example on the font metrics etc. What exactly would you like to print? Simple text, rich text? Can you please post some of the code that's responsible for printing the data?
-
@artwaw try to send you my text file, but a message from this Fourm tells me I don't have privileges enough to enclosed file. How can I do?
-
@alsa Post it in the post in here, wrap the source code in triple ` at the beginning and another triple at the end of the code block.
-
Model: TS400 - Serial/n: 500S_06_17 Date: 09:48:57 31/05/17 Temp: 25°C - Humidity: 55% checked by: AM - Fluke s/n: 1971 01 100 MONOPOLAR_CUT PURE_CUT 400 323.3 NONE 243 364 PASSED 02 350 MONOPOLAR_CUT PURE_CUT 400 381.5 NONE 312 400 PASSED 03 1500 MONOPOLAR_CUT PURE_CUT 400 215.5 NONE 178 267 PASSED 04 100 MONOPOLAR_CUT PURE_CUT 200 214.3 NONE 148 223 PASSED 05 350 MONOPOLAR_CUT PURE_CUT 200 215.7 NONE 160 240 PASSED
This is a small sample; text file is composed by 100 lines. It's a report of power delivery by an electrosurgical unit. Lines starts with step number and ends with PASSED or FAILED.
-
@alsa My solution would be to use QTextDocument - gather complete output, insert it to QTextDocument, set desired font etc. in the QTextDocument and use its built in method print(). This way you do not have to worry about pagination or anything else.
Please read about QTextDocument and associated classes - everything you need is there at hand.
Should you have any additional queries I would be happy to help. -
ok, I'll follow your advise; after I'll give you an answer about my trial.
Thanks artwaw