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

Images cannot float #353

Closed
antoyo opened this issue Nov 6, 2015 · 22 comments
Closed

Images cannot float #353

antoyo opened this issue Nov 6, 2015 · 22 comments
Assignees
Milestone

Comments

@antoyo
Copy link

antoyo commented Nov 6, 2015

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.

@mojavelinux
Copy link
Member

Floating images in PDF is extremely difficult, which is why we haven't done it yet. I do have a prototype of some text around images that can be found in editions (https://github.com/opendevise/editions/blob/master/lib/editions/pdf_extensions.rb#L88-L139). We're still considering how to integrate that into Asciidoctor PDF.

@antoyo
Copy link
Author

antoyo commented Nov 6, 2015

As an alternative, I tried using a table, but there is a lot of empty space at the bottom of the table.

Here is my code:

[cols="2*"]
|===
|Some +
text

|image:image.jpg[]
|===

Is it normal that there is a big white space at the bottom of the table?

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

Thanks for your help.

@mojavelinux
Copy link
Member

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

That definitely sounds like a bug. Images can throw off the cursor if not handled correctly, which could be happening in this case. I'll definitely look into it.

@mojavelinux
Copy link
Member

I think the problem is that inline images aren't properly expanding the cell height, which is the reason for #295 as well.

@atomfrede
Copy link

@mojavelinux Is there any possibility I can try your pdf extension with ascidoctor pdf, as our documentation departement would like to have floating images in pdf too.

@mojavelinux
Copy link
Member

@atomfrede Yes, by all means.

@cocowalla
Copy link

@atomfrede did you figure out how to try @mojavelinux PDF extension with Asciidoctor PDF? I'd also like to get floating images working

@atomfrede
Copy link

@cocowalla No I didn't had time. We made some changes to the documents, such that floating images are not required anymore at the moment.

@wingfire
Copy link

wingfire commented Jun 9, 2016

In the case "image in a table cell" i have the following effect with images wider than the cell:

  1. Images with a small height are show twice
  2. Higher images are shown once with a lot of white space below the image (White space has the same height like the image)
    Looks a bit like a duplication bug.

@mojavelinux
Copy link
Member

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.

@sylock
Copy link

sylock commented Apr 1, 2017

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

@bhagyas
Copy link

bhagyas commented Sep 27, 2018

Any updates on this issue?

@owjjh
Copy link

owjjh commented Oct 10, 2018

+1

@mojavelinux
Copy link
Member

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.

@oliviercailloux
Copy link

I'll be posting about this new strategy on the list later this week.

Has this ever been done? A search did not reveal anything really relevant.

@mojavelinux
Copy link
Member

I've been waiting on the 1.5.0 release to push out the official announcement. I have been talking about it rather extensively in the gitter channel, though. The prototype can be found at https://github.com/mogztter/asciidoctor-pdf.js, but it's still early days.

@Thanatermesis
Copy link

Same issue with epub3 renderings, I have no way to position images on the side with some text

Example code:

== Test section
.Title for image
image::einstein-relatividad.jpg[,340,role="related thumb left"]
Lorem Ipsum is simply dummy text of the printing a.....

So the HTML rendering (asciidoctor) renders very good, like:

HTML:

image


But for PDF or for EPUB3, it always renders it in a strange and unfriendly way (I tried different options for the images, nothing found to work nicely yet):


Epub:

image


PDF:

image

@mojavelinux
Copy link
Member

Please direct Asciidoctor EPUB3 feature requests to the issue tracker for that project. https://github.com/asciidoctor/asciidoctor-epub3/issues This issue tracker is only for issues that pertain to Asciidoctor PDF.

@mojavelinux
Copy link
Member

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.

@mojavelinux mojavelinux self-assigned this May 5, 2022
@mojavelinux mojavelinux modified the milestones: future, v2.0.0 May 5, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 7, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 7, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 7, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 7, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 12, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 13, 2022
…rter

- add supports_float_wrapping? to check if the following node supports wrapping around a float
- add ink_paragraph_in_float_box to handle logic to render paragraph within float box
- move cursor as content is inked in float box
- update example to show how to enlist a code block in float wrapping
- add additional information to float_box
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 13, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 13, 2022
…rter

- add supports_float_wrapping? to check if the following node supports wrapping around a float
- add ink_paragraph_in_float_box to handle logic to render paragraph within float box
- move cursor as content is inked in float box
- update example to show how to enlist a code block in float wrapping
- add additional information to float_box
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 14, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 14, 2022
…rter

- add supports_float_wrapping? to check if the following node supports wrapping around a float
- add ink_paragraph_in_float_box to handle logic to render paragraph within float box
- move cursor as content is inked in float box
- update example to show how to enlist a code block in float wrapping
- add additional information to float_box
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 14, 2022
- add supports_float_wrapping? method to check if the following node supports wrapping around a float
- add init_float_box method to set up float box
- call init_float_box method in convert image handler if float attribute is set on image and next block supports float wrapping
- add ink_paragraph_in_float_box to handle logic to render paragraph within float box
- add image-float-gap key to theme to control space around image float
- add extended converter example to docs to show how to enlist a code block in float wrapping
- add support for :indent_paragraphs option to formatted text box
- use image float in chronicles example to demonstrate
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 14, 2022
- add support for float attribute on block image, taking precedence over align attribute
- add supports_float_wrapping? method to check if the following node supports wrapping around a float
- add init_float_box method to set up float box
- call init_float_box method in convert image handler if float attribute is set on image and next block supports float wrapping
- add ink_paragraph_in_float_box to handle logic to render paragraph within float box
- add image-float-gap key to theme to control space around image float
- add extended converter example to docs to show how to enlist a code block in float wrapping
- add support for :indent_paragraphs option to formatted text box
- use image float in chronicles example to demonstrate
@mojavelinux
Copy link
Member

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.

@mcoderz
Copy link

mcoderz commented Nov 13, 2023

@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...

@mojavelinux
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests