参考资料:
http://blog.csdn.net/jdh99/article/details/42585987
http://www.oschina.net/question/1438043_235020
http://blog.163.com/ctcg326%40126/blog/static/758129102012451034427/
http://codego.net/447659/
部分样例:
1.
from PyQt5.QtWidgets import (QApplication, QWidget, QTableWidget,QPushButton,
QVBoxLayout,
QTableWidgetItem)
from PyQt5.QtGui import QPixmap, QPainter, QImage, QTextDocument
from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QPrintPreviewDialog
from PyQt5.QtCore import QRect, QPoint, QSize , Qt
# 有预览框
# 908204694@qq.com
#
def on_htmlButton_clicked():
printer =QPrinter(QPrinter.HighResolution)
#/* 打印预览 */
preview =QPrintPreviewDialog(printer,widget )
preview.paintRequested.connect(printHtml)
#
# 显示 预览框
#
#preview.exec()
preview.exec_()
def printHtml(printer):
html = """