Skip to content
New issue

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

Some floating images not being output to pdf since 0.42 #576

Closed
jessejoe opened this issue Feb 14, 2018 · 2 comments
Closed

Some floating images not being output to pdf since 0.42 #576

jessejoe opened this issue Feb 14, 2018 · 2 comments
Milestone

Comments

@jessejoe
Copy link

jessejoe commented Feb 14, 2018

Some float images that display fine in HTML are not being included in rendered WeasyPrint PDFs using 0.42+.

Reproduce

A very simple self-contained html document which has a couple images. This is a simplified version using actual CSS from Bootstrap (which is what my actual site is using):

<html>
<body>
<img src="https://i.imgur.com/mK3ufI3.png">
<div style="float: right;"><img style="max-width: 100%;" src="https://i.imgur.com/mK3ufI3.png"></div>
</body>
</html>

The output looks like this (or live https://jsfiddle.net/kzLhtejh/):
image

When generating a PDF from this HTML with WeasyPrint 0.41, the render looks correct:

$ pip install WeasyPrint==0.41
Collecting WeasyPrint==0.41
  Using cached WeasyPrint-0.41-py3-none-any.whl
...
Installing collected packages: WeasyPrint
Successfully installed WeasyPrint-0.41

$ python -c "from weasyprint import HTML; HTML('pdf.html').write_pdf('test.pdf')"
$

PDF render:
image

However when simply upgrading to WeasyPrint 0.42, the PDF render is missing the floated image:

$ pip install WeasyPrint==0.42
Collecting WeasyPrint==0.42
  Using cached WeasyPrint-0.42-py3-none-any.whl
...
Installing collected packages: WeasyPrint
  Found existing installation: WeasyPrint 0.41
    Uninstalling WeasyPrint-0.41:
      Successfully uninstalled WeasyPrint-0.41
Successfully installed WeasyPrint-0.42

$ python -c "from weasyprint import HTML; HTML('pdf.html').write_pdf('test.pdf')"
$

PDF render:
image

All subsequent versions of weasyprint have the same result. Here is a comparison of the two versions, there were quite a few changes to float logic - v0.41...v0.42

I did notice #561, however cairo versions do not have an affect, it's purely in WeasyPrint.

@jessejoe
Copy link
Author

A little more research...

Commit 1076b10 seems to have broken this.

If I reset the repo to this commit and install it:

$ git reset --hard 1076b106ea212c3ddc15730a6efda30f16c527e9
HEAD is now at 1076b106 Ignore intrinsic size for replaced boxes with percentage-based width

$ pip install -e .
Obtaining file:///Users/vagrant/jesse/WeasyPrint
...
Installing collected packages: WeasyPrint
  Running setup.py develop for WeasyPrint
Successfully installed WeasyPrint-0.41

The generated PDF is still broken. If I revert this commit:

$ git reset --hard HEAD~1
HEAD is now at a317b636 Fix typo

The generated PDF is correct.

Note that 1076b10 says it was implemented to fix #227.

@liZe liZe added this to the 43 milestone Feb 14, 2018
@liZe liZe closed this as completed in eaa27ac Feb 15, 2018
@liZe
Copy link
Member

liZe commented Feb 16, 2018

Thanks for the example, and sorry for the regression!

liZe added a commit that referenced this issue Feb 22, 2018
liZe added a commit that referenced this issue Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants