def handlePreview(self): dialog = QPrintPreviewDialog() dialog.setStyleSheet("table {border:1px; border-color:teal}") dialog.setWindowTitle('Adedoyin Adetunji') #dialog.showMaximized() #dialog.setMaximumSize(True) #dialog.setResolution(96) #dialog.setPageSize(QPrinter.Letter) #dialog.setPageMargins(5, 5, 5, 10, QPrinter.Millimeter) dialog.paintRequested.connect(self.handlePaintRequest) dialog.exec_()
def print_document(document, verse_key, pdf = False, copies=1, skip=False): printer = QPrinter(QPrinter.HighResolution) if not pdf: printer.setOutputFormat(QPrinter.NativeFormat) else: printer.setOutputFormat(QPrinter.PdfFormat) printer.setOutputFileName(ROOT + 'verse.pdf') printer.setPaperSize(QPrinter.A4) printer.setCopyCount(copies) printer.setPageMargins(10, 10, 10, 10, QPrinter.Millimeter) doc = QTextDocument() doc.setHtml(concatenate_pages(document, verse_key, skip)) dialog = QPrintPreviewDialog(printer) dialog.setWindowFlags(Qt.Window) dialog.setWindowTitle('Print preview: parse results') def preview(): doc.print_(printer) dialog.paintRequested.connect(preview) dialog.exec_()