def printProfile(self): printer = QPrinter(QPrinter.HighResolution) printer.setOutputFormat(QPrinter.PdfFormat) printer.setPaperSize(QPrinter.A4) printer.setOrientation(QPrinter.Landscape) printpreviewdlg = QPrintPreviewDialog() printpreviewdlg.paintRequested.connect(self.printRequested) printpreviewdlg.exec_()
def __printPreviewImage(self): """ Private slot to handle the Print Preview menu action. """ from PyQt4.QtGui import QPrintPreviewDialog if self.mainWidget is None: KQMessageBox.critical(None, self.trUtf8("Print Preview"), self.trUtf8("""There is no UI file loaded.""")) return settings = Preferences.Prefs.settings printer = KdeQt.KQPrinter.KQPrinter(mode = QPrinter.HighResolution) printer.setFullPage(True) if not KdeQt.isKDE(): printer.setPrinterName(settings.value("UIPreviewer/printername").toString()) printer.setPageSize( QPrinter.PageSize(settings.value("UIPreviewer/pagesize").toInt()[0])) printer.setPageOrder( QPrinter.PageOrder(settings.value("UIPreviewer/pageorder").toInt()[0])) printer.setOrientation( QPrinter.Orientation(settings.value("UIPreviewer/orientation").toInt()[0])) printer.setColorMode( QPrinter.ColorMode(settings.value("UIPreviewer/colormode").toInt()[0])) preview = QPrintPreviewDialog(printer, self) self.connect(preview, SIGNAL("paintRequested(QPrinter*)"), self.__print) preview.exec_()
def __printPreviewDiagram(self): """ Private slot called to show a print preview of the diagram. """ from PyQt4.QtGui import QPrintPreviewDialog printer = KdeQt.KQPrinter.KQPrinter(mode = QPrinter.ScreenResolution) printer.setFullPage(True) if Preferences.getPrinter("ColorMode"): printer.setColorMode(KdeQt.KQPrinter.Color) else: printer.setColorMode(KdeQt.KQPrinter.GrayScale) if Preferences.getPrinter("FirstPageFirst"): printer.setPageOrder(KdeQt.KQPrinter.FirstPageFirst) else: printer.setPageOrder(KdeQt.KQPrinter.LastPageFirst) printer.setPageMargins( Preferences.getPrinter("LeftMargin") * 10, Preferences.getPrinter("TopMargin") * 10, Preferences.getPrinter("RightMargin") * 10, Preferences.getPrinter("BottomMargin") * 10, QPrinter.Millimeter ) printer.setPrinterName(Preferences.getPrinter("PrinterName")) preview = QPrintPreviewDialog(printer, self) self.connect(preview, SIGNAL("paintRequested(QPrinter*)"), self.__print) preview.exec_()
def printMail(self): printer = QPrinter(mode=QPrinter.HighResolution) printer.setCreator("Daaq Mail") title = 'Daaq Mail' #title = validateFileName(title) printer.setDocName(title) printer.setOutputFileName(DOC_DIR + title + ".pdf") print_dialog = QPrintPreviewDialog(printer, self) print_dialog.paintRequested.connect(self.textViewer.print_) print_dialog.exec_()
def on_actionPrint_triggered(self): if self._printer is None: self._printer = QPrinter() self._printer = QPrinter(QPrinterInfo(self._printer), QPrinter.HighResolution) self._printer.setPaperSize(self._getPaperSize()) dialog = QPrintPreviewDialog(self._printer, parent = self) def updatePages(qprinter): self.scoreScene.printScore(qprinter, self.scoreView) dialog.paintRequested.connect(updatePages) dialog.exec_()
def open_print_preview_dialog(self): """ This member function calls print preview routine. """ aPrinter = QPrinter(QPrinter.HighResolution) printPrevDialog = QPrintPreviewDialog(aPrinter) self.connect(printPrevDialog, SIGNAL("paintRequested(QPrinter*)"), partial(io.printer, self.canvas)) # need this to make sure we take away focus from # any currently selected legend items self.canvas.clearFocus() printPrevDialog.exec_()
def on_actionPrint_triggered(self): if self._printer is None: self._printer = QPrinter() self._printer = QPrinter(QPrinterInfo(self._printer), QPrinter.HighResolution) self._printer.setPaperSize(self._getPaperSize()) dialog = QPrintPreviewDialog(self._printer, parent=self) def updatePages(qprinter): self.scoreScene.printScore(qprinter, self.scoreView) dialog.paintRequested.connect(updatePages) dialog.exec_()
def imprimir_documento(self): weditor = self.devolver_editor() if weditor is not None: # Extensión ext = weditor.nombre.split('.')[-1] # Se reemplaza la extensión por 'pdf' nombre = weditor.nombre.replace(ext, 'pdf') documento = QTextDocument(weditor.texto) printer = QsciPrinter() printer.setPageSize(QsciPrinter.A4) printer.setOutputFileName(nombre) printer.setDocName(nombre) dialogo = QPrintPreviewDialog(printer) dialogo.paintRequested.connect(documento.print_) dialogo.exec_()
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_file(fileName, printFunction): """This method print a file This method print a file, fileName is the default fileName, and printFunction is a funcion that takes a QPrinter object and print the file, the print method More info on:http://doc.qt.nokia.com/latest/printing.html""" printer = QPrinter(QPrinter.HighResolution) printer.setPageSize(QPrinter.A4) printer.setOutputFileName(fileName) printer.setDocName(fileName) preview = QPrintPreviewDialog(printer) preview.paintRequested[QPrinter].connect(printFunction) size = QApplication.instance().desktop().screenGeometry() width = size.width() - 100 height = size.height() - 100 preview.setMinimumSize(width, height) preview.exec_()
def on_actionExportPDF_triggered(self): try: printer = QPrinter(mode = QPrinter.HighResolution) printer.setPaperSize(self._getPaperSize()) printer.setOutputFormat(QPrinter.PdfFormat) if self.filename: outfileName = list(os.path.splitext(self.filename)[:-1]) outfileName = os.extsep.join(outfileName + ["pdf"]) else: outfileName = "Untitled.pdf" printer.setOutputFileName(outfileName) printer.setPaperSize(self._getPaperSize()) dialog = QPrintPreviewDialog(printer, parent = self) def updatePages(qprinter): self.scoreScene.printScore(qprinter, self.scoreView) dialog.paintRequested.connect(updatePages) dialog.exec_() self.updateStatus("Exported to PDF %s" % outfileName) except StandardError: QMessageBox.warning(self.parent(), "Export failed!", "Could not export PDF to " + outfileName)
def open_html_in_print_preview_from_gui_thread(html, html_document=QTextDocument, page_size=None, page_orientation=None): printer = QPrinter() printer.setPageSize(page_size or QPrinter.A4) printer.setOrientation(page_orientation or QPrinter.Portrait) dialog = QPrintPreviewDialog(printer) @QtCore.pyqtSlot(QPrinter) def render(printer): doc = html_document() doc.setHtml(html) doc.print_(printer) dialog.paintRequested.connect(render) # show maximized seems to trigger a bug in qt which scrolls the page down #dialog.showMaximized() desktop = QCoreApplication.instance().desktop() # use the size of the desktop instead to set the dialog size dialog.resize(desktop.width() * 0.75, desktop.height() * 0.75) dialog.exec_()
def on_actionExportPDF_triggered(self): try: printer = QPrinter(mode=QPrinter.HighResolution) printer.setPaperSize(self._getPaperSize()) printer.setOutputFormat(QPrinter.PdfFormat) if self.filename: outfileName = list(os.path.splitext(self.filename)[:-1]) outfileName = os.extsep.join(outfileName + ["pdf"]) else: outfileName = "Untitled.pdf" printer.setOutputFileName(outfileName) printer.setPaperSize(self._getPaperSize()) dialog = QPrintPreviewDialog(printer, parent=self) def updatePages(qprinter): self.scoreScene.printScore(qprinter, self.scoreView) dialog.paintRequested.connect(updatePages) dialog.exec_() self.updateStatus("Exported to PDF %s" % outfileName) except StandardError: QMessageBox.warning(self.parent(), "Export failed!", "Could not export PDF to " + outfileName)
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_()
def on_actionPrintPreview_triggered(self): dlg = QPrintPreviewDialog(self.printer, self) self.connect(dlg, Signals.paintRequested, self.webView.print_) dlg.exec_()
def accepted(self): self.padre.vistaprevia = False QPrintPreviewDialog.accepted(self)
def lunchPrintPreview(self): dialog = QPrintPreviewDialog() dialog.paintRequested.connect(self.handlePaintRequest) dialog.exec_()
def lunchPrintPreview(self): dialog = QPrintPreviewDialog() dialog.setContentsMargins(-5,-5,-5,-5) dialog.paintRequested.connect(self.handlePaintRequest) dialog.exec_()