We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a python code like this which converts url to pdf
import sys from PyQt5 import QtWidgets, QtWebEngineWidgets from PyQt5.QtCore import QUrl, QTimer, QSizeF from PyQt5.QtGui import QPageLayout, QPageSize from PyQt5.QtWidgets import QApplication import argparse def _fullScreenRequested(request): request.accept() loader.showFullScreen() def main(): parser = argparse.ArgumentParser(description="Just an example", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--url", help="Type url") args = parser.parse_args() config = vars(args) url = config['url'] app = QtWidgets.QApplication(sys.argv) loader = QtWebEngineWidgets.QWebEngineView() loader.setZoomFactor(1) layout = QPageLayout() layout.setPageSize(QPageSize(QSizeF(13, 20), QPageSize.Unit.Inch, "4x6 in page", QPageSize.SizeMatchPolicy.ExactMatch)) layout.setOrientation(QPageLayout.Portrait) loader.load(QUrl(url)) loader.page().pdfPrintingFinished.connect(lambda *args: QApplication.exit()) def emit_pdf(finished): QTimer.singleShot(2000, lambda: loader.page().printToPdf("test.pdf", pageLayout=layout)) loader.loadFinished.connect(emit_pdf) sys.exit(app.exec_()) if __name__ == '__main__': main()
I want to add page breaks to that pdf using my python code
mainly these two
https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-after
https://developer.mozilla.org/en-US/docs/Web/CSS/break-after
is it possible to add page breaks in my python code to the output pdf?
The text was updated successfully, but these errors were encountered:
hello whene i change this line
loader.load(QUrl(url))
to
loader.load(QUrl('https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-after'))
It kinda do what you want to do But I suggest using the print function that you can see what are you converting to pdf before you doing it
Sorry, something went wrong.
hello whene i change this line loader.load(QUrl(url)) to loader.load(QUrl('https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-after')) It kinda do what you want to do But I suggest using the print function that you can see what are you converting to pdf before you doing it
I think you are mistaken. I want to add extra page breaks for the output pdf
I'm not sure if I understand what you want exactly, but if you want to make it look like a pdf file with multiple page maybe try this
layout.setPageSize(QPageSize(getattr(QPageSize, "A4"))) layout.setOrientation(getattr(QPageLayout.Orientation, "Portrait")) #layout.setPageSize(QPageSize(QRectF(13, 20), QPageSize.Unit.Inch, "4x6 in page", QPageSize.SizeMatchPolicy.ExactMatch)) #layout.setOrientation(QPageLayout.Portrait)
No branches or pull requests
I have a python code like this which converts url to pdf
I want to add page breaks to that pdf using my python code
mainly these two
https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-after
https://developer.mozilla.org/en-US/docs/Web/CSS/break-after
is it possible to add page breaks in my python code to the output pdf?
The text was updated successfully, but these errors were encountered: