Closed tobiasgardner closed 3 weeks ago
Hi!
You need to add the --presentational-hints
option to handle the width
HTML attribute.
Note that using CSS instead of HTML attributes is often preferred for styling information.
Thank you @liZe! That did the trick! Or in my case, I used the following:
HTML(string=html_content).write_pdf(target=filename, presentational_hints=True)
@liZe May I ask another question... I am trying to setup the CSS so that my pages have:
I have tried a bunch of different ways but I am failing. If you have a guide/tutorial which shows how this can be done, I would appreciate it a lot :)
I am having problems with converting html to pdf with weasyprint (python).
It seems like it is not adhering to "width" in the img tag:
<img src="..." alt="Logo" width="300" />
No matter what I try here, it takes up 100% of the width of the page in the pdf output. However, it works when looking at the html code through a browser.
I have tried
I have created a html file here which illustrates the problem: https://gist.github.com/tobiasgardner/be6e9efba80f13e6aa6464cbcf8613ad
The output in the browser (html) looks like this.
The generated pdf can be found here: Weasyprint_debug.pdf