def doit(): with EbookIterator(sys.argv[-1]) as it: p = Printing(it, None) printer = QPrinter() of = sys.argv[-1]+'.pdf' printer.setOutputFileName(of) p.do_print(printer) print ('Printed to:', of) app.exit()
def doit(): with EbookIterator(sys.argv[-1]) as it: p = Printing(it, None) printer = QPrinter() of = sys.argv[-1] + '.pdf' printer.setOutputFileName(of) p.do_print(printer) print('Printed to:', of) app.exit()
def get_pdf_printer(opts, for_comic=False, output_file_name=None): # {{{ from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception("Not OK to use Qt") printer = QPrinter(QPrinter.HighResolution) 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 opts.output_profile.width > 9999 or opts.override_profile_size ): 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: w = opts.output_profile.comic_screen_size[0] if for_comic else 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: # Comic pages typically have their own margins, or their background # color is not white, in which case the margin looks bad printer.setPageMargins(0, 0, 0, 0, QPrinter.Point) else: printer.setPageMargins(opts.margin_left, opts.margin_top, opts.margin_right, opts.margin_bottom, QPrinter.Point) printer.setOutputFormat(QPrinter.PdfFormat) printer.setFullPage(for_comic) if output_file_name: printer.setOutputFileName(output_file_name) if isosx and not for_comic: # Ensure we are not generating enormous image based PDFs printer.setOutputFormat(QPrinter.NativeFormat) return printer
def get_pdf_printer(opts, for_comic=False, output_file_name=None): # {{{ from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = QPrinter(QPrinter.HighResolution) 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 \ opts.output_profile.width > 9999 or opts.override_profile_size: 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: w = opts.output_profile.comic_screen_size[0] if for_comic else \ 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: # Comic pages typically have their own margins, or their background # color is not white, in which case the margin looks bad printer.setPageMargins(0, 0, 0, 0, QPrinter.Point) else: printer.setPageMargins(opts.margin_left, opts.margin_top, opts.margin_right, opts.margin_bottom, QPrinter.Point) printer.setOutputFormat(QPrinter.PdfFormat) printer.setFullPage(for_comic) if output_file_name: printer.setOutputFileName(output_file_name) if isosx and not for_comic: # Ensure we are not generating enormous image based PDFs printer.setOutputFormat(QPrinter.NativeFormat) return printer
# proxies = {'http': 'http://126.179.0.206:9090' } headers = {'User-Agent': 'MultiFlashcards/fcset.py 0.1'} url = 'http://ekskursja.pl/wp-content/plugins/flashcards/flashcards.json.php?name=contigo&id=29072' print url # response = urllib.urlopen(url, proxies=proxies) response = urllib.urlopen(url) data = json.loads(response.read()) app = QApplication([]) printer = QPrinter(QPrinter.HighResolution) printer.setOutputFormat(QPrinter.PdfFormat) printer.setPageSize(QPrinter.A6) printer.setOrientation(QPrinter.Landscape) printer.setPageMargins(0, 0, 0, 0, QPrinter.Millimeter) printer.setFullPage(False) bkgimg = QImage() if not bkgimg.load("KosyMost.png", format="png"): print "Not loaded" printer.setOutputFileName("contigo.pdf") painter = QPainter(printer) maxx = painter.device().width()