I cant print my pdf file using QPrinter, I figured it needs to be set to html to print it and now im getting this error on terminal “QPrintDialog: Cannot be used on non-native printers”. And does setting it to html like this change what my pdf file look like?.
def print_pdf(self, pdffile):
printer = QPrinter()
printer.setOutputFileName(pdffile)
printer.setPageSize(QPageSize(QPageSize.PageSizeId.A6))
# Create a QTextDocument to hold the contents of the PDF file
document = QTextDocument()
document.setHtml("<html><body><img src='file://" + pdffile + "'/></body></html>") # Load PDF content
# a print dialog
print_dialog = QPrintDialog(printer, self)
if print_dialog.exec() == QPrintDialog.DialogCode.Accepted:
# Print the document
document.print(printer)