Printing PDF Report from HTML template leads to unexpected result

Hi there,

i am refactoring our print templates to HTML.

Doing so, i use nested [div id=“xxx”][/div] Tags. Some of these Tags do not have content in [Body] but getting the content from css-style in [head].

When printed, this arrangement gets condensed to [div id=“xxx”/] (only for these “empty” Tags like shown above) which subsequently leads to malformed PDF (most content not to be seen at all).

I am able to fix this issue placing short comment in the tag like [div id=“xxx”][!-- Comment --][/div].

Am i doing something wrong or may this be an code issue to be fixed?


For sure, i am using sharp brackets but that could not be handelt by the Forum.

You should report your problem to

1 Like

Bug reported to Weasyprint Team.
Looking forward to their answer.


Will be good to put the link here

Should not have filed the bug by email but opening an issue on git hub.
So prepared a working and a failing case.

While preparing templates, I come to the conclusion that it may not be caused by Weasyprint as both templates lead to the same (good) result (Executed on Windows Plattform).

Whereas the test from Tryton gives an erroneous result (Running on Linux Plattform).

Should have run both tests on my Tryton Server for a meaningful result.

Please find attached templates, test-skripts and resulting pdf files. Whoops. ZIP not allowed.

With your tests nobody can conclude anything because you are testing Weasyprint on a different platform than where you have bogus behavior.

@ced … I agree with you absolutely.

That’s why I’ve now run my examples on the Tryton server itself.
In the same python virtual environment as the tryton server process.

Printing my Template…

  • with [div][div/]-Tag directly with weasyprint → Works fine.
  • with [div/]-Tag directly with weasyprint → Leads to missing content in the generated file.
  • with [div][div/]-Tag as a regular Tryton Report → Leads to missing content in the generated file.
  • with [div][!-- Comment --][div/]-Tag as a regular Tryton Report → Works fine.

Some component illegally condenses the [div][div/]-Tag to a [div/]-Tag and it doesn’t appear to me to be weasyprint itself. I can verify this condensing in generated output when setting output-format temporarily from PDF to HTML in Tryton Report-Definition.

Weasyprint team’s response to my bug report as follows:

In HTML, the slash at the end of tags is just ignored. It means that “[div /]” is exactly like “[div]”, not “[div][/div]”.

HTML Standard

Some tags are marked as void (img, input, br…) and don’t need a closing tag, that’s why you can write “[img]” (or “[img/]”) with no need to close it. As “[div]” is not one of them, you need a “[/div]” closing tag.

1 Like

To be complete, as Genshi is used as template engine, the HTML must be XML compliant.

Are you actually using a trailing slash in the closing tag <div><div/>?
If so, please note that the correct syntax is <div></div>.

(Please use proper mark up instead of „rewriting“ angled brackets by squared ones. Thx.)

No. Using it in the following Format:
<div id="pageGuides"><!-- Content in CSS --></div>

Also, I am currently trying to check the XML compliance of the template.