asciidoctor-pdf: Images cannot float

Hello. We can have floating image in the HTML5 backend using this syntax:

image::image.jpg[role="right"]

but it does not work in the PDF backend.

Thanks to fix this issue.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 14
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I’m thrilled to report that after all the changes and improvements that were made to the code for the 2.0.0 release, it became possible to implement this feature.

The way it works is that it will wrap successive paragraphs next to the floating image (an block image with the float attribute). The float box will be cleared once the content extends past the bottom of the image or another type of block is encountered. However, the code also adds a framework for enlisting additional block types in the float wrapping, which is explained in the documentation.

At this point, I seriously doubt Asciidoctor PDF will ever support floating. It’s not just a matter of time. This technology stack (specifically Prawn) just doesn’t provide the tools we need to do it without an enormous amount of logic.

We’re going to be pivoting our PDF strategy to leverage web technologies (HTML and CSS). Once we do that, we’ll be able to use all kinds of advanced layouts, including floating. I’ll be posting about this new strategy on the list later this week.

So, what about a proper float implementation into PDF? Is it still in the pipe?

As I’ve said many times before, what needs to be done to get AsciiDoc table cell content to work is to write a custom table cell implementation for Prawn that recurses back into the converter to handle arbitrary AsciiDoc content. Once that is done, in theory, we get support for all block-level AsciiDoc in a table cell for “free”. Until then, trying to render AsciiDoc content in a table cell by cherry picking it is just a huge hack.

Please direct usage questions to the project chat at https://chat.asciidoctor.org. Thanks.

@mojavelinux Is there a way to use [.float-group] with PDF? I’m traying put three image side by side, and I can do it in HTML, but not in PDF…

It seems to happen only when using an image inside a table.

This issue was addressed by the fix for #1515. Here’s how it looks now when using a table for layout.

screenshot

It takes some fiddling to get the amount of text right per cell, but at least there is no extra bottom margin now.