Created
April 3, 2020 14:36
-
-
Save ThomasG77/72fd711bda2ec0c8b95a0dacd2dbb942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtPrintSupport import QPrinter | |
from PyQt5.QtGui import QFont, QPainter, QTextDocument | |
printer = QPrinter(QPrinter.HighResolution); | |
printer.setOutputFormat(QPrinter.PdfFormat); | |
printer.setOutputFileName("/tmp/out.pdf"); | |
document = QTextDocument(); | |
html = "<a href='http://www.google.com'>google</a>"; | |
document.setHtml(html); | |
painter = QPainter(); | |
painter.begin(printer); | |
document.drawContents(painter) | |
painter.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment