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

Weasyprint hanging on image with percentage height style #327

Closed
mohag opened this issue Jun 24, 2016 · 3 comments
Closed

Weasyprint hanging on image with percentage height style #327

mohag opened this issue Jun 24, 2016 · 3 comments
Assignees
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered
Milestone

Comments

@mohag
Copy link

mohag commented Jun 24, 2016

This file manages to hang WeasyPrint 0.29 for me when converting to PDF: (Removing the style fixes it)

<!DOCTYPE html>
<html>
<head> <title></title> </head>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" style="width:30%;height:30%;" >
</body>
</html>

OS: Ubuntu 14.04 LTS

pip package listing

# pip list
apt-xapian-index (0.45)
argparse (1.2.1)
cairocffi (0.7.2)
CairoSVG (1.0.22)
cffi (1.7.0)
chardet (2.0.1)
colorama (0.2.5)
cssselect (0.9.2)
Cython (0.20.1post0)
html5lib (0.9999999)
lxml (3.6.0)
pip (1.5.4)
pycparser (2.14)
pycrypto (2.6.1)
Pyphen (0.9.4)
python-apt (0.9.3.5ubuntu2)
python-debian (0.1.21-nmu2ubuntu2)
requests (2.2.1)
setuptools (3.3)
six (1.10.0)
ssh-import-id (3.21)
tinycss (0.3)
urllib3 (1.7.1)
WeasyPrint (0.29)
wheel (0.24.0)
wsgiref (0.1.2)
@mohag mohag changed the title Weasyprint hanging on data URL image with percentage height and width style Weasyprint hanging on image with percentage height and width style Jun 24, 2016
@mohag
Copy link
Author

mohag commented Jun 24, 2016

Data URL does not seem to be a requirement

@liZe liZe added crash Problems preventing documents from being rendered bug Existing features not working as expected labels Jun 24, 2016
@mohag
Copy link
Author

mohag commented Jun 24, 2016

Height seems to be the issue, leaving just width works fine.

@mohag mohag changed the title Weasyprint hanging on image with percentage height and width style Weasyprint hanging on image with percentage height style Jun 24, 2016
@liZe
Copy link
Member

liZe commented Jun 24, 2016

Height seems to be the issue, leaving just width works fine.

You're right, WeasyPrint crashes with replaced elements with height set in percentages.

Traceback (most recent call last):
  File "/home/lize/Informatique/weasyprint/weasyprint.py", line 5, in <module>
    main()
  File "/home/lize/Informatique/weasyprint/weasyprint/__main__.py", line 156, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File "/home/lize/Informatique/weasyprint/weasyprint/__init__.py", line 200, in write_png
    self.render(stylesheets, enable_hinting=True)
  File "/home/lize/Informatique/weasyprint/weasyprint/__init__.py", line 133, in render
    return Document._render(self, stylesheets, enable_hinting)
  File "/home/lize/Informatique/weasyprint/weasyprint/document.py", line 322, in _render
    return cls([Page(p, enable_hinting) for p in page_boxes],
  File "/home/lize/Informatique/weasyprint/weasyprint/document.py", line 322, in <listcomp>
    return cls([Page(p, enable_hinting) for p in page_boxes],
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/__init__.py", line 51, in layout_document
    pages = list(make_all_pages(context, root_box))
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/pages.py", line 562, in make_all_pages
    page_number)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/pages.py", line 514, in make_page
    positioned_boxes, positioned_boxes, adjoining_margins)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/blocks.py", line 437, in block_container_layout
    adjoining_margins)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/blocks.py", line 322, in block_container_layout
    for line, resume_at in lines_iterator:
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 48, in iter_line_boxes
    device_size, absolute_boxes, fixed_boxes)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 100, in get_next_linebox
    line_fixed, line_placeholders, waiting_floats)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 603, in split_inline_box
    waiting_floats)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 518, in split_inline_level
    device_size, absolute_boxes, fixed_boxes)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 408, in atomic_box
    inline_replaced_box_layout(box, device_size)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 330, in inline_replaced_box_layout
    inline_replaced_box_width_height(box, device_size)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/inlines.py", line 340, in inline_replaced_box_width_height
    replaced_box_height(box, device_size)
  File "/home/lize/Informatique/weasyprint/weasyprint/layout/min_max.py", line 44, in wrapper
    if box.height > box.max_height:
TypeError: unorderable types: str() > float()

@liZe liZe self-assigned this Jun 24, 2016
@liZe liZe closed this as completed in b3706b0 Mar 25, 2017
@liZe liZe added this to the v0.37 milestone Mar 25, 2017
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 1, 2017
Version 0.39
------------

Released on 2017-06-24.

Bug fixes:

* Fix the use of WeasyPrint's URL fetcher with CairoSVG.


Version 0.38
------------

Released on 2017-06-16.

Bug fixes:

* `#477 <https://github.com/Kozea/WeasyPrint/issues/477>`_:
  Don't crash on font-face's src attributes with local functions.


Version 0.37
------------

Released on 2017-06-15.

WeasyPrint now depends on tinycss2 instead of tinycss.

New features:

* `#437 <https://github.com/Kozea/WeasyPrint/issues/437>`_:
  Support local links in generated PDFs.

Bug fixes:

* `#412 <https://github.com/Kozea/WeasyPrint/issues/412>`_:
  Use a NullHandler log handler when WeasyPrint is used as a library.
* `#417 <https://github.com/Kozea/WeasyPrint/issues/417>`_,
  `#472 <https://github.com/Kozea/WeasyPrint/issues/472>`_:
  Don't crash on some line breaks.
* `#327 <https://github.com/Kozea/WeasyPrint/issues/327>`_:
  Don't crash with replaced elements with height set in percentages.
* `#467 <https://github.com/Kozea/WeasyPrint/issues/467>`_:
  Remove incorrect line breaks.
* `#446 <https://github.com/Kozea/WeasyPrint/pull/446>`_:
  Let the logging module do the string interpolation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants