Well even though it can print ok directly to my test printer when using:
QPrinter printer(QPrinter::HighResolution);
To copy to clipboard, switch view to plain text mode
the test application does seem to generate quite a large pdf weighing in at 4,164 KB for a single page single image renderred widget. This is, however, not in the same league as the Xerox prints which are over 50 times larger. I'm not sure how significant this is as it is my first attempt at any form of Qt PDF file generation.
I ran a test with
QPrinter printer(QPrinter::ScreenResolution);
To copy to clipboard, switch view to plain text mode
and it produced a file of 197KB.
Likewise with
QPrinter printer(QPrinter::PrinterResolution);
To copy to clipboard, switch view to plain text mode
the file size produced was 131KB
To my untrained eyes this seems quite a significant difference is that what is expected in terms of resolution quality?
I have attached the rapidly thrown together demo code and I apologise for any potentially obvious mistakes. I shall continue testing different parameters.
void MainWindow::menuPrintTest(){
double xscale; double yscale; double scale; double printerWidth ; double printerHeight ; double widgetWidth; double widgetHeight ;
QFont printFont
("courier",
16);
printFont.setFixedPitch(TRUE);
qteTestPrintRequest ->setFont(printFont );
qteTestPrintRequest ->setFixedHeight(500); //NEW
qteTestPrintRequest ->setFixedWidth(750); //NEW
widgetWidth = qteTestPrintRequest ->width() ; //+200; //NEW MOD
widgetHeight = qteTestPrintRequest ->height() ; //+300; //NEW MOD
QString qsConcat
= "Test Printout For Checking XP Print Request Bug\n";
for (int i=0; i<30; i++){ qsConcat+= "Test Printout for Checking XP Print Request Bug\n" ; }
qteTestPrintRequest->append( qsConcat );
printer.
setOutputFormat(QPrinter::PdfFormat);
//PDF ADD printer.setOutputFileName("Test.pdf"); //PDF ADD
if ( !docName.isEmpty()) {
printer.setDocName (docName);
}
//QPrintDialog dialog(&printer); //PDF REMOVE
//if ( dialog.exec() ) { //PDF REMOVE
{
painter.begin(&printer);
printerWidth = printer.pageRect().width();
printerHeight = printer.pageRect().height();
xscale = printerWidth/(widgetWidth);
yscale = printerHeight/(widgetHeight);
scale = qMin(xscale, yscale);
painter.scale(scale, scale);
qteTestPrintRequest ->render(&painter); //qteTestPrintRequest->print(&printer);
painter.end();
} //QPAINTER CTOR BRACE
}
//}else{} //PDF REMOVE
delete qteTestPrintRequest;
}
void MainWindow::menuPrintTest(){
double xscale; double yscale; double scale; double printerWidth ; double printerHeight ; double widgetWidth; double widgetHeight ;
QFont printFont("courier", 16);
printFont.setFixedPitch(TRUE);
QTextEdit *qteTestPrintRequest = new QTextEdit("",w);
qteTestPrintRequest ->setFont(printFont );
qteTestPrintRequest ->setFixedHeight(500); //NEW
qteTestPrintRequest ->setFixedWidth(750); //NEW
widgetWidth = qteTestPrintRequest ->width() ; //+200; //NEW MOD
widgetHeight = qteTestPrintRequest ->height() ; //+300; //NEW MOD
QString qsConcat = "Test Printout For Checking XP Print Request Bug\n";
for (int i=0; i<30; i++){ qsConcat+= "Test Printout for Checking XP Print Request Bug\n" ; }
qteTestPrintRequest->append( qsConcat );
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat); //PDF ADD
printer.setOutputFileName("Test.pdf"); //PDF ADD
QString docName = "Test Plot";
if ( !docName.isEmpty()) {
docName.replace (QRegExp (QString::fromLatin1 ("\n")), tr (" -- "));
printer.setDocName (docName);
}
//QPrintDialog dialog(&printer); //PDF REMOVE
//if ( dialog.exec() ) { //PDF REMOVE
{
QPainter painter;
painter.begin(&printer);
printerWidth = printer.pageRect().width();
printerHeight = printer.pageRect().height();
xscale = printerWidth/(widgetWidth);
yscale = printerHeight/(widgetHeight);
scale = qMin(xscale, yscale);
painter.scale(scale, scale);
qteTestPrintRequest ->render(&painter); //qteTestPrintRequest->print(&printer);
painter.end();
} //QPAINTER CTOR BRACE
}
//}else{} //PDF REMOVE
delete qteTestPrintRequest;
}
To copy to clipboard, switch view to plain text mode
Added after 4 minutes:
Changing the size of the renderred QTextEdit widget seems to only change the file size proportionally.
http://doc.qt.nokia.com/4.7-snapshot...interMode-enum
States that for QPrinter::PrinterResolution
This value is deprecated. Is is equivalent to ScreenResolution on Unix and HighResolution on Windows and Mac. Due do the difference between ScreenResolution and HighResolution, use of this value may lead to non-portable printer code.
and for QPrinter::HighResolution
On Windows, sets the printer resolution to that defined for the printer in use. For PostScript printing, sets the resolution of the PostScript driver to 1200 dpi.
If it weren't for this I would be looking at substituting QPrinter::PrinterResolution for QPrinter::HighResolution.
Still my big question is if it is ok to use QTextEdit->render(&painter)
In response to your post:
The point is to see how large the document is when still in postscript format. Apparently later the printer driver rasterizes the document which inflates its size. How much memory does the printer have?
The printer still manages to print the document it just takes a long time to send the data to the printer. In the test the 213MB was the size observed in the printer document queue on the PC running the test app.
It is a fairly modern, high spec printer serving a large-ish office. It must have a sizeable memory. All of the other printers tested were of a lower spec to the problem printer.
Bookmarks