mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
c5364f3a77
commit
b7dfad3f18
@ -45,29 +45,24 @@ 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:
|
if opts.output_profile.short_name == 'default' or \
|
||||||
# On OSX, the native engine can only produce a single page size
|
opts.output_profile.width > 9999:
|
||||||
# (usually A4). The Qt engine on the other hand produces image based
|
if custom_size is None:
|
||||||
# PDFs. If we set a custom page size using QSizeF the native engine
|
printer.setPaperSize(paper_size(opts.paper_size))
|
||||||
# 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 \
|
|
||||||
opts.output_profile.width > 9999:
|
|
||||||
if custom_size is None:
|
|
||||||
printer.setPaperSize(paper_size(opts.paper_size))
|
|
||||||
else:
|
|
||||||
printer.setPaperSize(QSizeF(custom_size[0], custom_size[1]), unit(opts.unit))
|
|
||||||
else:
|
else:
|
||||||
w = opts.output_profile.comic_screen_size[0] if for_comic else \
|
custom_size = True
|
||||||
opts.output_profile.width
|
printer.setPaperSize(QSizeF(custom_size[0], custom_size[1]), unit(opts.unit))
|
||||||
h = opts.output_profile.comic_screen_size[1] if for_comic else \
|
else:
|
||||||
opts.output_profile.height
|
custom_size = True
|
||||||
dpi = opts.output_profile.dpi
|
w = opts.output_profile.comic_screen_size[0] if for_comic else \
|
||||||
printer.setPaperSize(QSizeF(float(w) / dpi, float(h) / dpi), QPrinter.Inch)
|
opts.output_profile.width
|
||||||
|
h = opts.output_profile.comic_screen_size[1] if for_comic else \
|
||||||
|
opts.output_profile.height
|
||||||
|
dpi = opts.output_profile.dpi
|
||||||
|
printer.setPaperSize(QSizeF(float(w) / dpi, float(h) / dpi), QPrinter.Inch)
|
||||||
|
|
||||||
if for_comic:
|
if for_comic:
|
||||||
# Comic pages typically have their own margins, or their background
|
# Comic pages typically have their own margins, or their background
|
||||||
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user