Hi, newbie on the forums and also newbie at Qt programming.
I am here because I have a problem, (which I researched for a fix and I am aware it's the same issue as This one on C++) and I can't find a way to fix on Python 3.5.
The issue: When I try to print my widget to a PDF the result is this one:
It should fit the entire A4 page but it resizes it to that small section (yeah, that red rectangle).
MzSHRX75RRSmfkvcgucxLQ.jpg
The code:
from PyQt5.
QtPrintSupport import
QPrinter
# Print options
printer.
setOrientation(QPrinter.
Portrait)printer.
setPageMargins(15,
15,
15,
15,
QPrinter.
Millimeter)printer.setFullPage(True)
printer.
setOutputFormat(QPrinter.
PdfFormat)printer.setOutputFileName("testfile.pdf")
# Render/Paint it
painter.begin(printer)
MyWidget.render(painter)
painter.end()
from PyQt5.QtGui import QPainter
from PyQt5.QtPrintSupport import QPrinter
# Print options
printer = QPrinter(QPrinter.HighResolution)
printer.setOrientation(QPrinter.Portrait)
printer.setPaperSize(QPrinter.A4)
printer.setPageSize(QPrinter.A4)
printer.setPageMargins(15, 15, 15, 15, QPrinter.Millimeter)
printer.setFullPage(True)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName("testfile.pdf")
# Render/Paint it
painter = QPainter()
painter.begin(printer)
MyWidget.render(painter)
painter.end()
To copy to clipboard, switch view to plain text mode
Assuming This documentation is accurate, the setFullpage on true should fix it. so what am I missing?
Bookmarks