我成功地将 HTML 转换为 PDF(或打印为 pdf)。但是,Cookies 和隐私政策声明印在每页的底部。如何删除此通知或接受 cookie?(任何网站域的解决方案)
import os
import sys
from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
def html_to_pdf(html, pdf):
app = QtWidgets.QApplication(sys.argv)
page = QtWebEngineWidgets.QWebEnginePage()
def handle_print_finished(filename, status):
print("finished", filename, status)
QtWidgets.QApplication.quit()
def handle_load_finished(status):
if status:
page.printToPdf(pdf)
else:
print("Failed")
QtWidgets.QApplication.quit()
page.pdfPrintingFinished.connect(handle_print_finished)
page.loadFinished.connect(handle_load_finished)
page.setUrl(QtCore.QUrl(html))
app.exec_()
if __name__ == "__main__":
html_to_pdf("https://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag?rq=1", "test.pdf")