weasyprint

Re-displaying the current heading after a page break

吃可爱长大的小学妹 提交于 2021-02-18 06:59:24
问题 I'm creating a document with WeasyPrint. I have sections that have names, some of which might span across multiple pages. When a section is too long, a page break occurs. What I am trying to do is to re-display the current section's name, ideally with the same formatting. The following MWE shows how the section title is not displayed after a page break: <html> <body> <h1>First section</h1> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p style="break

Re-displaying the current heading after a page break

烂漫一生 提交于 2021-02-18 06:59:09
问题 I'm creating a document with WeasyPrint. I have sections that have names, some of which might span across multiple pages. When a section is too long, a page break occurs. What I am trying to do is to re-display the current section's name, ideally with the same formatting. The following MWE shows how the section title is not displayed after a page break: <html> <body> <h1>First section</h1> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p style="break

Weasyprint Dockerfile for GAE

我只是一个虾纸丫 提交于 2021-02-05 12:15:16
问题 I am trying to install weasyprint on gae, i know we can install external libraries by passing it in a Dockerfile by changing the runtime from python to custom in app.yaml. I am having trouble creating the Dockerfile for weasyprint libraries. 回答1: Here is a simple example that I wrote following these instructions. I have tested it and the deployment on GAE has been successful for me: Dockerfile FROM gcr.io/google-appengine/python # Create a virtualenv for dependencies. This isolates these

Weasyprint Dockerfile for GAE

拜拜、爱过 提交于 2021-02-05 12:14:16
问题 I am trying to install weasyprint on gae, i know we can install external libraries by passing it in a Dockerfile by changing the runtime from python to custom in app.yaml. I am having trouble creating the Dockerfile for weasyprint libraries. 回答1: Here is a simple example that I wrote following these instructions. I have tested it and the deployment on GAE has been successful for me: Dockerfile FROM gcr.io/google-appengine/python # Create a virtualenv for dependencies. This isolates these

How to get WeasyPrint working with Google App Engine

泪湿孤枕 提交于 2021-01-27 19:15:57
问题 I'm new to GAE, WeasyPrint and Python. I realise that WeasyPrint relies on quite a few dependences. I have had a look at the install documentation for Windows. But I cant seem to figure out how I would get it working on GAE. Is there no way to download an version with all the dependencies included and just copy it to my project folder? 回答1: Its not possible to run WeasyPrint directly on appengine. You should always read the docs on the dependencies. WeasyPrint is dependent on cairo and pango

WeasyPrint HTML-to-image conversion: how to adapt image size to content?

那年仲夏 提交于 2020-05-28 08:25:05
问题 I need to convert some HTML to an image in Python and I am using WeasyPrint. I would like the image size to adapt to the content. When using the following, I get an image which is much larger than content (an A4?): # !pip install weasyprint import weasyprint as wsp img_filepath = 'test.png' html_source = ''' <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Ciao!</title> </head> <body> Hello World! </body> </html> ''' html = wsp.HTML(string=html_source) html.write_png(img

Django and weasyprint, merge pdf

廉价感情. 提交于 2020-05-10 06:55:17
问题 It's possible to merge multiple pdf in django with weasyprint? I have something like this: def verpdf(request, pk): odet = get_object_or_404(Note, pk = pk) template = get_template('pdfnot.html') template1 = get_template('pdfnot2.html') p1 = template.render({'odet': odet}).encode(encoding="ISO-8859-1") p2 = template1.render({'note':odet}).encode(encoding="ISO-8859-1") pdf1 = HTML(string=p1).render() pdf2 = HTML(string=p2).render() all_pages = [po for po in pdf1.pages for doc in pdf2.pages] pdf

Django and weasyprint, merge pdf

末鹿安然 提交于 2020-05-10 06:53:30
问题 It's possible to merge multiple pdf in django with weasyprint? I have something like this: def verpdf(request, pk): odet = get_object_or_404(Note, pk = pk) template = get_template('pdfnot.html') template1 = get_template('pdfnot2.html') p1 = template.render({'odet': odet}).encode(encoding="ISO-8859-1") p2 = template1.render({'note':odet}).encode(encoding="ISO-8859-1") pdf1 = HTML(string=p1).render() pdf2 = HTML(string=p2).render() all_pages = [po for po in pdf1.pages for doc in pdf2.pages] pdf