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

Resize an image in a table cell if it is taller than the page height #1024

Merged
merged 3 commits into from Dec 11, 2021

Conversation

akrabat
Copy link
Member

@akrabat akrabat commented Aug 30, 2021

An image cannot be rendered across a page boundary and so if it is too tall, then it needs to be resized. This happens automatically for plain images, but not for those in a table (including lists and figures in rst2pdf).

This is because the availHeight parameter passed to wrap() is set to a very large value by reportlab on the assumption that a table cell's data can be rendered over a page boundary. We therefore need to set the correct maximum height into the MyImage instances within a DelayedTable so that they can be resized correctly.

Fixes #966.
@nfraprado: I would appreciate your review.

When it is used in in reference PDFs at full size, it may result in a
file that's bigger than the pre-commit checks allow.
An image cannot be rendered across a page boundary and so if it is too
tall, then it needs to be resized. This happens automatically for plain
images, but not for those in a table (including lists and figures in
rst2pdf).

This is because the availHeight parameter passed to wrap() is set to a
very large value by reportlab on the assumption that a table cell's data
can be rendered over a page boundary. We therefore need to set the
correct maximum height into the MyImage instances within a DelayedTable
so that they can be resized correctly.
While figures are also tables, we can't be sure that they always will be
and so we test that an image in a table that's too tall for the page is
corrrectly resized.
@akrabat akrabat closed this in ae62cb8 Dec 11, 2021
@akrabat akrabat merged commit ae62cb8 into rst2pdf:master Dec 11, 2021
@akrabat akrabat deleted the resizing-image-in-figure branch January 2, 2022 09:55
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

Successfully merging this pull request may close these issues.

Images using figure directive that are too tall aren't resized and make rst2pdf abort
1 participant