-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Support for flexible row heights based on content size #2342
Comments
Hi! There are many reasons why WeasyPrint doesn’t give the right rendering, mainly:
Hopefully, none of them are related to grid layout, whose support is much more solid than flex in WeasyPrint, even if it’s not complete (see #2145). With minor changes to the CSS (set An image is obviously missing from the rendering (because of the quite bad support of flex), but at least we can see the overall layout. Even if your example is probably a combination of other flex layout problems already reported, let’ keep this issue open because your examples are great! (And here’s a secret: we’ll be soon working on flex really hard, so… Stay tuned!) |
@liZe Thanks for a thoughtful response! I'm glad the examples are helpful and great to hear flex improvements are coming :) After putting the above example together, I realized how little it actually uses CSS grid. I've put together a similar example using only grid to demonstrate differences between what I'm seeing in Chrome vs. what Weasyprint outputs for a PDF. I'll include the updated example here, but happy to also create a new issue if that's easier. The difference in approach is as follows:
My expectation is that the (Note that I'm hard-coding the Here's a view leveraging Chrome's grid inspector: Chrome OutputWeasyprint OutputI might be missing a few lines of CSS to make this snap into place, but here's the output I'm getting currently. CSS
HTML
|
Could you please open a separate issue for this bug? |
Context
I have a program that will automatically generate page layouts given images in different orientations across an arbitrary number of rows and columns. A common case is 2 landscape images in a single column, or maybe a single portait-orientation photo. Chrome can handle this very well with flexbox and I've had good success generating the templates on the backend and having the layouts rendered as expected on the front-end.
Here's a screenshot from Chrome of a few layout variations using some simple placeholder images:
However, when exporting these layouts to PDF, I've hit the limits of Weasyprint's flex support, so I'm seeing if I can make it work with grid layout...or highlight the issues for the team :)
As shown below, Weasyprint can't render these layouts at all; I assume this is because grid display is still work-in-progress, but I have a hunch that Chrome is more forgiving that Weasyprint and I'll need some additional code in the CSS; I'm just not sure what doesn't work because grid display is in-progress, or lazy CSS on my part.
Layout A
The first row has 2 landscape photos that fill the max width, allowing the second row the fill the remaining within the layout on the page.
Layout B
For comparison, here's the same layout, but with a single horizontal photo in the first column. As expected, the first row takes up more horizontal space and the layout accommodates accordingly.
Weasyprint: Layout A
Weasyprint chokes on Layout A. The code is shown below.
Layout A
CSS
Layout C
I can generate something vaguely similar to Layout A if I swap the images for div's with fixed height/width, but this isn't very useful as the images have fixed heights that I want the grid rows to adjust to.
CSS
HTML
Chrome Output
Weasyprint Output
The text was updated successfully, but these errors were encountered: