Hello,
you can also use the print() method to print without the page number!
The key is, that the QTextDocument needs a valid pageSize.
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName( fileName );
// printer.setPageMargins(0.925, 0.8, 0.5, 0.8, QPrinter::Inch);
paperSize.setWidth(printer.width());
paperSize.setHeight(printer.height());
document->setHtml(html);
document->setPageSize(paperSize); // the document needs a valid PageSize
document->print(&printer);
QPrinter printer(QPrinter::ScreenResolution);
printer.setPaperSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName( fileName );
// printer.setPageMargins(0.925, 0.8, 0.5, 0.8, QPrinter::Inch);
QSizeF paperSize;
paperSize.setWidth(printer.width());
paperSize.setHeight(printer.height());
document->setHtml(html);
document->setPageSize(paperSize); // the document needs a valid PageSize
document->print(&printer);
To copy to clipboard, switch view to plain text mode
When you refer the source code of print(), then you will recognize that the < QPointF pageNumberPos; > is only defined when there is no valid QTextDocument.pageSize().
In printPage() the page number will be just printed, if pageNumberPos is not null.
So just set a valid QTextDocumtent.pageSize() and you have no page numbers on your printed document.
I hope this bug will be fixed in a future release. (It's a reported bug)
good luck
Bookmarks