QPrintDialog - Let OSX handle PDF printing

If the user selects to Save as PDF in the native print dialog, then let
OSX generate the PDF. Primarily this is to fix QTBUG-38820 where by
setting the output mode to PdfFormat we prevent the native print dialog
from being called again. This was a regression in 5.1. It also allows
for smaller, better quality PDFs with the ability to select text until
QTBUG-13826 / QTBUG-10094 fixes the font rendering. Once QTBUG-36112 is
also fixed we can consider changing back to Qt's internal PDF support.
See also QTBUG-36687 and QTBUG-26054 which are related.

Task-number: QTBUG-38820
Change-Id: I74bd885902860ac70068ab25e95765c7f0ee911c
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
bb10
John Layt 2014-06-04 16:40:05 +01:00 committed by Shawn Rutledge
parent 6668f5becf
commit 92ea91836e
1 changed files with 8 additions and 5 deletions

View File

@ -121,19 +121,22 @@ QT_USE_NAMESPACE
if (dialog->maxPage() < dialog->toPage())
dialog->setFromTo(dialog->fromPage(), dialog->maxPage());
}
// Keep us in sync with file output
PMDestinationType dest;
// If the user selected print to file, the session has been
// changed behind our back and our d->ep->session object is a
// dangling pointer. Update it based on the "current" session
// Keep us in sync with chosen destination
PMDestinationType dest;
PMSessionGetDestinationType(session, settings, &dest);
if (dest == kPMDestinationFile) {
// QTBUG-38820
// If user selected Print to File, leave OSX to generate the PDF,
// otherwise setting PdfFormat would prevent us showing dialog again.
// TODO Restore this when QTBUG-36112 is fixed.
/*
QCFType<CFURLRef> file;
PMSessionCopyDestinationLocation(session, settings, &file);
UInt8 localFile[2048]; // Assuming there's a POSIX file system here.
CFURLGetFileSystemRepresentation(file, true, localFile, sizeof(localFile));
printer->setOutputFileName(QString::fromUtf8(reinterpret_cast<const char *>(localFile)));
*/
} else {
PMPrinter macPrinter;
PMSessionGetCurrentPrinter(session, &macPrinter);