PDA

View Full Version : Image Quality when printing to PDF



JayMan8081
20th August 2010, 15:56
I am trying to see if there is a way to get better image quality when using QPrinter to print to a PDF file. Currently the image is extremely blurry at the time of printing. The type of images are typically high-resolution map images where the level of detail needs to be maintained when printing to PDF. I am currently using version 4.5.3 of QT.

ChrisW67
21st August 2010, 00:30
Does setting QPrinter::HighResolution on the QPrinter change the situation?

JayMan8081
23rd August 2010, 13:49
Setting the QPrinter to QPrinter::HighResolution just blew the whole document up to crazy sizes. Normally the document should be on a single page and with HighResolution set to became 32 pages and nothing fit on a single page.

ChrisW67
23rd August 2010, 23:49
How are you painting to the printer? How are you handling the logical coordinate system for the page versus the source? Pagination? For 32 pages to be generated you must be issuing QPrinter::newPage() calls that you were not issuing before.

JayMan8081
25th August 2010, 18:19
You were correct there was a call to QPrinter::newPage() that I was missing before. It appears that my problem is not as simple as I had initially thought it to be. I am painting to the printer using a QPainter which in turn is using a combination of QTextDocument and QPainter::drawText. The QTextDocument is written to by using QTextCursor in conjunction with QTextBlock, QTextTable, and QImage. When the QTextDocument::drawContents() call is made it seems as though that call is not applying the QPrinter resolution evenly to all of its various elements. The text within the QTextTables and QTextBlocks is not scaling appropriately for the resolution. Thanks for your help so far and hopefully now that I've learned more about the application it may provide some insight into where things are going astray?