1
0
Fork 0
mirror of https://github.com/Phantop/dotfiles synced 2024-11-25 00:03:29 +00:00
dotfiles/bin/pagepdf

26 lines
762 B
Python
Executable file

#!/usr/bin/env python3
import sys
from PyQt6.QtCore import QUrl
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtGui import QPageLayout
from PyQt6.QtGui import QPageSize
from PyQt6.QtCore import QMarginsF
def save_img():
#size = wv.page().contentsSize().toSize()
#wv.resize(size)
#wv.grab().save('dump.png', b'PNG')
#page_layout = QPageLayout(QPageSize(QPageSize.PageSizeId.A2), QPageLayout.Orientation.Portrait, QMarginsF())
wv.printToPdf("dump.pdf")
if __name__ == '__main__':
app = QApplication(sys.argv)
wv = QWebEngineView()
wv.loadFinished.connect(save_img)
wv.pdfPrintingFinished.connect(sys.exit)
wv.load(QUrl.fromUserInput(sys.argv[1]))
app.exec()