(Mar-12-2024, 03:28 PM)deanhystad Wrote: Why not this?
def export_html1(self, tableV, file_path): with open(file_path, "w") as file: file.write(self.formHTML(tableV))
Thank you, this worked for html. Apparently i went too far with Qt way on this one. Right now looking for some other way to create pdf...
Ok, i've found the problem. I don't know how to control Margins but at least without them it works:
def export_pdf(self, tableV, file_path): html = self.formHTML(tableV) document = QTextDocument() document.setHtml(html) printer = QPrinter(QPrinter.PrinterMode.HighResolution) printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat) printer.setOutputFileName(file_path) printer.setPageSize(QPageSize(QPageSize.PageSizeId.A4)) document.print(printer)