I am trying to export data from QTextEdit. I am taking QTextDocument and use QPrinter with Pdf format. It prints right, keeps bold and underline formatting, but font is very small and doesn't use font settings from the text edit. The font size formatting is definitely there, because when I export source html, the formatting is all right. What I am doing wrong? The code looks like this:
path
= str
(QFileDialog.
getSaveFileName(None,
"Get export file name", \
'Untitled.pdf', "*.pdf", \
'Untitled.pdf'))
if path == '':
return
if not path.endswith('.pdf'):
path += '.pdf'
printer.
setOutputFormat(QPrinter.
PdfFormat) printer.setOutputFileName(path)
self.document().print_(printer)
path = str(QFileDialog.getSaveFileName(None, "Get export file name", \
'Untitled.pdf', "*.pdf", \
'Untitled.pdf'))
if path == '':
return
if not path.endswith('.pdf'):
path += '.pdf'
printer = QPrinter(QPrinter.HighResolution)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(path)
printer.setPaperSize(QPrinter.A4)
self.document().print_(printer)
To copy to clipboard, switch view to plain text mode
Bookmarks