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 exportToPdf(self): printer = QPrinter(QPrinter.PrinterResolution) printer.setOutputFormat(QPrinter.PdfFormat) printer.setPaperSize(QPrinter.A4) printer.setOutputFileName('export_sample.pdf') document = self.ui.textEdit.document() size = QSizeF(printer.paperRect().size()) document.setPageSize(size) document.print(printer) print('###')
def setup_ui(self): self.l = l = QFormLayout(self) l.addRow( QLabel(_('Print %s to a PDF file') % elided_text(self.book_title))) self.h = h = QHBoxLayout() self.file_name = f = QLineEdit(self) val = dynamic.get(self.OUTPUT_NAME, None) if not val: val = expanduser('~') else: val = os.path.dirname(val) f.setText(os.path.abspath(os.path.join(val, self.default_file_name))) self.browse_button = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))), b.setToolTip( _('Choose location for PDF file')) b.clicked.connect(self.choose_file) h.addWidget(f), h.addWidget(b) f.setMinimumWidth(350) w = QLabel(_('&File:')) l.addRow(w, h), w.setBuddy(f) self.paper_size = ps = QComboBox(self) ps.addItems([ a.upper() for a in sorted(self.paper_size_map, key=numeric_sort_key) ]) previous_size = vprefs.get('print-to-pdf-page-size', None) if previous_size not in self.paper_size_map: previous_size = (QPrinter().pageLayout().pageSize().name() or '').lower() if previous_size not in self.paper_size_map: previous_size = 'a4' ps.setCurrentIndex(ps.findText(previous_size.upper())) l.addRow(_('Paper &size:'), ps) tmap = { 'left': _('&Left margin:'), 'top': _('&Top margin:'), 'right': _('&Right margin:'), 'bottom': _('&Bottom margin:'), } for edge in 'left top right bottom'.split(): m = QDoubleSpinBox(self) m.setSuffix(' ' + _('inches')) m.setMinimum(0), m.setMaximum(3), m.setSingleStep(0.1) val = vprefs.get('print-to-pdf-%s-margin' % edge, 1) m.setValue(val) setattr(self, '%s_margin' % edge, m) l.addRow(tmap[edge], m) self.pnum = pnum = QCheckBox(_('Add page &number to printed pages'), self) pnum.setChecked(vprefs.get('print-to-pdf-page-numbers', True)) l.addRow(pnum) self.show_file = sf = QCheckBox(_('&Open PDF file after printing'), self) sf.setChecked(vprefs.get('print-to-pdf-show-file', True)) l.addRow(sf) l.addRow(self.bb)
def __init__(self): QMainWindow.__init__(self, flags=Qt.Window) self.menu = MenuBarWidget() self.status_bar = StatusBar() self.editor = TextEditor() self.translator = QTranslator() # I18N 관련 self.filename = str() self.change_locale("translate\\" + QLocale.system().name() + ".qm") # 시스템 로케일 사용 self.document_prt = QPrinter() self.init_window() self.init_setting()
def generatePDF(self, contenido): hoy = str(datetime.datetime.now().year) + str( datetime.datetime.now().month) + str( datetime.datetime.now().day) + str( datetime.datetime.now().hour) + str( datetime.datetime.now().minute) + str( datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + 'LIST') + '.pdf' fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> <hr> <br> <p> SALDOS </p> <br> """ + contenido doc = QTextDocument() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)
def initialize(self, choices=None): from calibre.utils.icu import numeric_sort_key if self.system_default_paper_size is None: PaperSizes.system_default_paper_size = 'a4' if iswindows or ismacos: # On Linux, this can cause Qt to load the system cups plugin # which can crash: https://bugs.launchpad.net/calibre/+bug/1861741 PaperSizes.system_default_paper_size = 'letter' if QPrinter().pageSize() == QPagedPaintDevice.Letter else 'a4' if not choices: from calibre.ebooks.conversion.plugins.pdf_output import PAPER_SIZES choices = PAPER_SIZES for a in sorted(choices, key=numeric_sort_key): s = getattr(QPageSize, a.capitalize()) sz = QPageSize.definitionSize(s) unit = {QPageSize.Millimeter: 'mm', QPageSize.Inch: 'inch'}[QPageSize.definitionUnits(s)] name = '{} ({:g} x {:g} {})'.format(QPageSize.name(s), sz.width(), sz.height(), unit) self.addItem(name, a)
def initialize(self, choices=None): from calibre.utils.icu import numeric_sort_key if self.system_default_paper_size is None: QComboBox.system_default_paper_size = 'letter' if QPrinter( ).pageSize() == QPagedPaintDevice.Letter else 'a4' if not choices: from calibre.ebooks.conversion.plugins.pdf_output import PAPER_SIZES choices = PAPER_SIZES for a in sorted(choices, key=numeric_sort_key): s = getattr(QPageSize, a.capitalize()) sz = QPageSize.definitionSize(s) unit = { QPageSize.Millimeter: 'mm', QPageSize.Inch: 'inch' }[QPageSize.definitionUnits(s)] name = '{} ({:g} x {:g} {})'.format(QPageSize.name(s), sz.width(), sz.height(), unit) self.addItem(name, a)
def generatePDF(self, contenido): hoy = str(datetime.datetime.now().year) + str(datetime.datetime.now().month) + str(datetime.datetime.now().day) + str(datetime.datetime.now().hour) + str(datetime.datetime.now().minute) + str(datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + 'LIST') + '.pdf' fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> <hr> <br> <p> SALDOS </p> <br> """+ contenido doc = QTextDocument() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)
def printPage(self): assert(self._page) printer = QPrinter() printer.setCreator('APP %s (%s)' % (const.VERSION, const.WWWADDRESS)) printer.setDocName(gVar.appTools.filterCharsFromFilename(self.title())) dialog = QPrintDialog(printer, self) dialog.setOptions(QAbstractPrintDialog.PrintToFile | QAbstractPrintDialog.PrintShowPageSize) if not const.OS_WIN: dialog.setOption(QAbstractPrintDialog.PrintPageRange) dialog.setOption(QAbstractPrintDialog.PrintCollateCopies) if dialog.exec_() == QDialog.Accepted: if dialog.printer().outputFormat() == QPrinter.PdfFormat: self._page.printToPdf(dialog.printer().outputFileName(), dialog.printer().pageLayout()) del dialog else: self._page.print_(dialog.printer())
def createFactura(self, listTransaccion, subNom, idRecibo): hoy = str(datetime.datetime.now().year) + str(datetime.datetime.now().month) + str(datetime.datetime.now().day) + str(datetime.datetime.now().hour) + str(datetime.datetime.now().minute) + str(datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + subNom) + '.pdf' listTransaccionTable = "" for transaccion in listTransaccion: listTransaccionTable += """ <tr height="80"> <td width="10%" align="center" > <br>""" + str(transaccion[1]) + """<br> </td> <td width="20%" > <br> """ + str(transaccion[3]) + """<br> </td> <td width="50%" > <br> """ + str(transaccion[4]) + """<br> </td> <td width="10%" align="right" > <br> $ """ + str(transaccion[5]) + """ <br> </td> <td width="10%" align="right" > <br> $ """ + str( int(transaccion[1]) * float(transaccion[5])) + """ <br> </td> </tr> """ nombre = "" apellido = "" if(self.tipoTransaccion == "VENTA"): nombre = self.cliente.getNombre() apellido = self.cliente.getApellido() elif(self.tipoTransaccion == "COMPRA"): nombre = self.proveedor.getNombre() apellido = self.proveedor.getDescripcion() total = self.winPrincipal.lblTotal.text() fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> Perfumeria La que vende perfumes <br> LABOULAYE, CORDOBA, ARGENTINA <br> TEL: 0351-111111 <br> MAIL: [email protected] <br> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> _______________________________________________________________________________________________________ <p> DATOS DEL CLIENTE: </p> <br> <table> <tr> <td> NOMBRE: """+ nombre +""" <br> APELLIDO: """ + apellido + """ <br> </td> <td> </td> </tr> </table> <br> _______________________________________________________________________________________________________ <br> <p> DETALLES DE LA COMPRA: </p> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr style=" background-color: gray; border-style: inset;"> <td width="10%" align="center" valign="middle"> <b> CANT </b> </td> <td width="20%" align="center" valign="middle"> <b> PRODUCTO </b> </td> <td width="50%" align="center" valign="middle"> <b> DESCRIPCION </b> </td> <td width="10%" align="center" valign="middle"> <b> PREC <br>UNIT </b> </td> <td width="10%" align="center" valign="middle"> <b> PREC <br>TOT </b> </td> </tr> </table> <br> <br> <br> <br> <table height="350" width="600" style="border-color: gray; border-width: .4px; border-collapse: collapse;"> """ + listTransaccionTable + """ </table> <br> <br> <table width="600" border="0.5" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr > <td width="90%" align="right"> <br> TOTAL.................................................................................................................. <br> </td> <td width="10%" align="center"> <br> $ """ + total + """<br> </td> </tr> </table> <br> <br> <br> <p width="600" align="center" style=" font-size: 10; " > Por cualquier consulta, sobre este recibo, dirigirse al local que se encuentra ubicado en la calle independencia 450. <br> O Comunicarse a los telefonos 03382-123123123 / 4231231 </p> <br> <br> <br> <br> <br> _______________________________________________________________________________________________________ <br> <table width="600"> <tr> <td align="right" width="80%"> FECHA/HORA : """+ fecha + """ </td> <td align="right"> N° : """+ str(idRecibo) +""" </td> </tr> </table> _______________________________________________________________________________________________________ """ doc = QTextDocument() doc.setHtml(html) #doc.setDefaultStyleSheet(style) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url) """
def generateList(self): hoy = str(datetime.datetime.now().year) + str( datetime.datetime.now().month) + str( datetime.datetime.now().day) + str( datetime.datetime.now().hour) + str( datetime.datetime.now().minute) + str( datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + 'LIST') + '.pdf' listTable = "" for lista in self.listProducto: listTable += """ <tr height="80"> <td width="60%" align="left" > <br>""" + str(lista[1]) + """<br> </td> <td width="20%" align="center"> <br> """ + str( lista[3]) + """<br> </td> <td width="20%" align="center"> <br> """ + str( lista[2]) + """<br> </td> </tr> """ fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> <hr> <br> <p> LISTADO DE PRODUCTOS SIN STOCK : </p> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr style=" background-color: gray; border-style: inset;"> <td width="60%" align="center" valign="middle"> <b> PRODUCTOS </b> </td> <td width="20%" align="center" valign="middle"> <b> CANTIDAD MINIMA </b> </td> <td width="20%" align="center" valign="middle"> <b> CANTIDAD </b> </td> </tr> </table> <br> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> """ + listTable + """ </table> <br> <br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br> <hr> <br> <table width="600"> <tr> <td align="right" width="100%"> FECHA/HORA : """ + fecha + """ </td> </tr> </table> <hr> """ doc = QTextDocument() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)
def generarRecibo(self, listDetail, subName, id, header): """ @param listDetail: lista de detalles @param subName: Sub-nombre para generar el PDF @param id: Id del recibo """ self.nombrePdf = '../archivos/' + str(self.hoy + subName) + '.pdf' listDetalHtml = self.generateTableTransaction(listDetail, header) nombre = "" apellido = "" if (self.tipoTransaccion == "VENTA"): nombre = self.cliente.getNombre() apellido = self.cliente.getApellido() elif (self.tipoTransaccion == "COMPRA"): nombre = self.proveedor.getNombre() apellido = self.proveedor.getDescripcion() total = self.winPrincipal.lblTotal.text() fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> Perfumeria La que vende perfumes <br> LABOULAYE, CORDOBA, ARGENTINA <br> TEL: 0351-111111 <br> MAIL: [email protected] <br> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> _______________________________________________________________________________________________________ <p> DATOS DEL CLIENTE: </p> <br> <table> <tr> <td> NOMBRE: """ + nombre + """ <br> APELLIDO: """ + apellido + """ <br> </td> <td> </td> </tr> </table> <br> _______________________________________________________________________________________________________ <br> <p> DETALLES DE LA COMPRA: </p> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr style=" background-color: gray; border-style: inset;"> <td width="10%" align="center" valign="middle"> <b> CANT </b> </td> <td width="20%" align="center" valign="middle"> <b> PRODUCTO </b> </td> <td width="50%" align="center" valign="middle"> <b> DESCRIPCION </b> </td> <td width="10%" align="center" valign="middle"> <b> PREC <br>UNIT </b> </td> <td width="10%" align="center" valign="middle"> <b> PREC <br>TOT </b> </td> </tr> </table> <br> <br> <br> <br> <table height="350" width="600" style="border-color: gray; border-width: .4px; border-collapse: collapse;"> """ + listTransaccionTable + """ </table> <br> <br> <table width="600" border="0.5" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr > <td width="90%" align="right"> <br> TOTAL.................................................................................................................. <br> </td> <td width="10%" align="center"> <br> $ """ + total + """<br> </td> </tr> </table> <br> <br> <br> <p width="600" align="center" style=" font-size: 10; " > Por cualquier consulta, sobre este recibo, dirigirse al local que se encuentra ubicado en la calle independencia 450. <br> O Comunicarse a los telefonos 03382-123123123 / 4231231 </p> <br> <br> <br> <br> <br> _______________________________________________________________________________________________________ <br> <table width="600"> <tr> <td align="right" width="80%"> FECHA/HORA : """ + fecha + """ </td> <td align="right"> N° : """ + str(idRecibo) + """ </td> </tr> </table> _______________________________________________________________________________________________________ """ doc = QTextDocument() doc.setHtml(html) #doc.setDefaultStyleSheet(style) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)
def get_pdf_printer(opts, for_comic=False, output_file_name=None): # {{{ from calibre.gui2 import must_use_qt must_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 createList(self): hoy = str(datetime.datetime.now().year) + str(datetime.datetime.now().month) + str(datetime.datetime.now().day) + str(datetime.datetime.now().hour) + str(datetime.datetime.now().minute) + str(datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + 'LIST') + '.pdf' listTable = "" for lista in self.listFinal: listTable += """ <tr height="80"> <td width="40%" align="center" > <br>""" + str(lista[0]) + """<br> </td> <td width="40%" > <br> """ + str(lista[1]) + """<br> </td> <td width="20%" > <br> """ + str(lista[2]) + """<br> </td> </tr> """ subtitle = "Listado de clientes con deudas : " if self.type == 'PROV': subtitle = "Listado de deudas a proveedores : " fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> <hr> <br> <p> """+ subtitle + """ </p> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr style=" background-color: gray; border-style: inset;"> <td width="40%" align="center" valign="middle"> <b> APELLIDO </b> </td> <td width="40%" align="center" valign="middle"> <b> NOMBRE </b> </td> <td width="20%" align="center" valign="middle"> <b> DEUDA </b> </td> </tr> </table> <br> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> """ + listTable + """ </table> <br> <br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br> <hr> <br> <table width="600"> <tr> <td align="right" width="100%"> FECHA/HORA : """+ fecha + """ </td> </tr> </table> <hr> """ doc = QTextDocument() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)
def createRecibo(self, subNom, idRecibo, total, totDeuda, totPago): hoy = str(datetime.datetime.now().year) + str( datetime.datetime.now().month) + str( datetime.datetime.now().day) + str( datetime.datetime.now().hour) + str( datetime.datetime.now().minute) + str( datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + subNom) + '.pdf' listTransaccionTable = "" nombre = "" apellido = "" if (self.state == "COBRANZA"): nombre = self.cliente.getNombre() apellido = self.cliente.getApellido() elif (self.state == "PAGO"): nombre = self.proveedor.getNombre() apellido = self.proveedor.getDescripcion() totalDeuda = float(totDeuda) deudaString = "$ " + "{0:.2f}".format(totalDeuda) totalPago = float(totPago) pagoString = "$ +" + "{0:.2f}".format(totalPago) total = float(totalDeuda + totalPago) totalString = "{0:.2f}".format(total) fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> Perfumeria La que vende perfumes <br> LABOULAYE, CORDOBA, ARGENTINA <br> TEL: 0351-111111 <br> MAIL: [email protected] <br> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> _______________________________________________________________________________________________________ <p> DATOS DEL CLIENTE: </p> <br> <table> <tr> <td> NOMBRE: """ + nombre + """ <br> APELLIDO: """ + apellido + """ <br> </td> <td> </td> </tr> </table> <br> _______________________________________________________________________________________________________ <br> <p> DETALLES DEL RECIBO: </p> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr style=" background-color: gray; border-style: inset;"> <td width="80%" align="center" valign="middle"> <b> DESCRIPCION </b> </td> <td width="20%" align="center" valign="middle"> <b> MONTO </b> </td> </tr> </table> <br> <br> <br> <br> <table height="350" width="600" style="border-color: gray; border-width: .4px; border-collapse: collapse;"> <tr height="80"> <td width="80%" align="left" > <br>DEUDA <br> </td> <td width="20%" > <br> """ + str( deudaString) + """<br> </td> </tr> <tr height="80"> <td width="80%" align="left" > <br> PAGO<br> </td> <td width="20%" > <br> """ + str( pagoString) + """<br> </td> </tr> </table> <br> <br> <table width="600" border="0.5" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr > <td width="90%" align="right"> <br> TOTAL.................................................................................................................. <br> </td> <td width="10%" align="center"> <br> $ """ + str(totalString) + """<br> </td> </tr> </table> <br> <br> <br> <br> <br> <br> <p width="600" align="center" style=" font-size: 10; " > Por cualquier consulta, sobre este recibo, dirigirse al local que se encuentra ubicado en la calle independencia 450. <br> O Comunicarse a los telefonos 03382-123123123 / 4231231 </p> <br> <br> <br> <br> <br> _______________________________________________________________________________________________________ <br> <table width="600"> <tr> <td align="right" width="80%"> FECHA/HORA : """ + fecha + """ </td> <td align="right"> N° : """ + str(idRecibo) + """ </td> </tr> </table> _______________________________________________________________________________________________________ """ doc = QTextDocument() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)
def generateList(self): hoy = str(datetime.datetime.now().year) + str(datetime.datetime.now().month) + str(datetime.datetime.now().day) + str(datetime.datetime.now().hour) + str(datetime.datetime.now().minute) + str(datetime.datetime.now().second) nombrePdf = '../archivos/' + str(hoy + 'LIST') + '.pdf' listTable = "" for lista in self.listProducto: listTable += """ <tr height="80"> <td width="60%" align="left" > <br>""" + str(lista[1]) + """<br> </td> <td width="20%" align="center"> <br> """ + str(lista[3]) + """<br> </td> <td width="20%" align="center"> <br> """ + str(lista[2]) + """<br> </td> </tr> """ fecha = str(datetime.datetime.now()) html = """ <table width="600"> <tr width="600" color="#000000"> <td width="80%"> </td> <td width="20%" align="right"> <IMG SRC="kde1.png"> </td> </tr> </table> <hr> <br> <p> LISTADO DE PRODUCTOS SIN STOCK : </p> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> <tr style=" background-color: gray; border-style: inset;"> <td width="60%" align="center" valign="middle"> <b> PRODUCTOS </b> </td> <td width="20%" align="center" valign="middle"> <b> CANTIDAD MINIMA </b> </td> <td width="20%" align="center" valign="middle"> <b> CANTIDAD </b> </td> </tr> </table> <br> <br> <table width="600" height="0" style="border-color: black; border-width: 0.5px; border-spacing: 0;"> """ + listTable + """ </table> <br> <br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br> <hr> <br> <table width="600"> <tr> <td align="right" width="100%"> FECHA/HORA : """+ fecha + """ </td> </tr> </table> <hr> """ doc = QTextDocument() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName(nombrePdf) printer.setOutputFormat(QPrinter.PdfFormat) doc.print(printer) printer.newPage() url = QUrl url = QUrl(nombrePdf) QDesktopServices.openUrl(url)