PDF Output: Set engine on OS X based upon paper size as stanard sizes are fixed with Qt 4.8.1. Custom sizes are still broken.

This commit is contained in:
John Schember 2012-04-22 20:55:50 -04:00
parent c5364f3a77
commit b7dfad3f18

View File

@ -45,23 +45,18 @@ def get_pdf_printer(opts, for_comic=False, output_file_name=None):
if not is_ok_to_use_qt(): if not is_ok_to_use_qt():
raise Exception('Not OK to use Qt') raise Exception('Not OK to use Qt')
custom_size = False
printer = QPrinter(QPrinter.HighResolution) printer = QPrinter(QPrinter.HighResolution)
custom_size = get_custom_size(opts) custom_size = get_custom_size(opts)
if isosx and not for_comic:
# On OSX, the native engine can only produce a single page size
# (usually A4). The Qt engine on the other hand produces image based
# PDFs. If we set a custom page size using QSizeF the native engine
# produces unreadable output, so we just ignore the custom size
# settings.
printer.setPaperSize(paper_size(opts.paper_size))
else:
if opts.output_profile.short_name == 'default' or \ if opts.output_profile.short_name == 'default' or \
opts.output_profile.width > 9999: opts.output_profile.width > 9999:
if custom_size is None: if custom_size is None:
printer.setPaperSize(paper_size(opts.paper_size)) printer.setPaperSize(paper_size(opts.paper_size))
else: else:
custom_size = True
printer.setPaperSize(QSizeF(custom_size[0], custom_size[1]), unit(opts.unit)) printer.setPaperSize(QSizeF(custom_size[0], custom_size[1]), unit(opts.unit))
else: else:
custom_size = True
w = opts.output_profile.comic_screen_size[0] if for_comic else \ w = opts.output_profile.comic_screen_size[0] if for_comic else \
opts.output_profile.width opts.output_profile.width
h = opts.output_profile.comic_screen_size[1] if for_comic else \ h = opts.output_profile.comic_screen_size[1] if for_comic else \
@ -77,13 +72,13 @@ def get_pdf_printer(opts, for_comic=False, output_file_name=None):
printer.setPageMargins(opts.margin_left, opts.margin_top, printer.setPageMargins(opts.margin_left, opts.margin_top,
opts.margin_right, opts.margin_bottom, QPrinter.Point) opts.margin_right, opts.margin_bottom, QPrinter.Point)
printer.setOrientation(orientation(opts.orientation)) printer.setOrientation(orientation(opts.orientation))
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setFullPage(for_comic) printer.setFullPage(for_comic)
if output_file_name: if output_file_name:
printer.setOutputFileName(output_file_name) printer.setOutputFileName(output_file_name)
if isosx and not for_comic: if isosx and not custom_size:
# Ensure we are not generating enormous image based PDFs
printer.setOutputFormat(QPrinter.NativeFormat) printer.setOutputFormat(QPrinter.NativeFormat)
else:
printer.setOutputFormat(QPrinter.PdfFormat)
return printer return printer