How to prevent page number from printing
-
When I run the below code at the the end it prints the page number. Is there a way to prevent that from happening
from PySide6.QtGui import ( QPageSize, QPageLayout, QTextBlockFormat, QTextCursor, QTextDocument, QTextFormat, ) from PySide6.QtWidgets import QApplication from PySide6.QtPrintSupport import QPrinter, QPrintPreviewDialog app = QApplication() printer = QPrinter(QPrinter.HighResolution) dialog = QPrintPreviewDialog(printer) def handle_paint_requested(printer): document = QTextDocument() cursor = QTextCursor(document) blockFormat = QTextBlockFormat() text=open('sampletext.txt').read() cursor.insertBlock(blockFormat) cursor.insertText(text) document.print_(printer) dialog.paintRequested.connect(handle_paint_requested) dialog.exec() -
Hi,
Set the document page size to a valid value.
For the reasons, see the code of the QTextDocument::print function.
-
Hi,
Set the document page size to a valid value.
For the reasons, see the code of the QTextDocument::print function.
-
The pageSize property says that the point is 1/72 of an inch when printing.