You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replying to this thread from 5 years ago with a possible solution to how to add a cover page: make 2 WeasyPrint.HTML objects, one containing the cover page and another containing the rest of the content and merge them together.
This applies at least to weasyprint==60.1.
# Assemble cover page Document, should generate only 1 page within weasy_coverpage_doc.pages.coverpage_html_string="... your function that returns coverpage html string ..."weasy_coverpage_html=HTML(string=coverpage_html_string)
weasy_coverpage_doc=weasy_coverpage_html.render()
# Assemble content Document.html_string="... your function that returns content html string ..."weasy_html=HTML(string=html_string, base_url=markdown_path)
weasy_doc=weasy_coverpage_html.render()
# Insert first (will be only) page from weasy_coverpage_doc into pages in weasy_doc.weasy_doc.pages.insert(0, weasy_coverpage_doc.pages[0])
weasy_doc.write_pdf(f"content_with_coverpage.pdf")
How to add cover page?
How to hide some contents in first page only?
The text was updated successfully, but these errors were encountered: