Prawn::Errors::CannotFit in Java but not with command line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Prawn::Errors::CannotFit in Java but not with command line

phgiraud
Hello,

I get the following error when using Java version of Asciidoctor PDF:

avr. 22, 2020 9:46:12 AM org.asciidoctor.jruby.internal.JRubyAsciidoctor convertFile
SEVERE: (CannotFit) Prawn::Errors::CannotFit

Using the latest distribution (via Maeven Central):
asciidoctorj-pdf-1.5.3.jar
asciidoctorj-2.2.0.jar

The problem seems to be with a table in the document that contains images.

When using Linux command line with the following Gem installed:
asciidoctor (2.0.10, 1.5.8, 1.5.7.1)
asciidoctor-pdf (1.5.0.beta.4, 1.5.0.beta.3, 1.5.0.alpha.16)

I do not get this error.

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Prawn::Errors::CannotFit in Java but not with command line

abelsromero
I also reproduced the issue running the latests pdf gem 'asciidoctor-pdf (1.5.3)' and the code below. I think the best thing is to open an issue in the repo https://github.com/asciidoctor/asciidoctor-pdf. If you can test the different versions and see what version broke it would be a great help.

|===
|Header 1 |Header 2 |Header 3

| image:sunset.jpg[scaledwidth=75%]
|Column 2, row 1
|Column 3, row 1

|===




Traceback (most recent call last):
        80: from /home/asalgadr/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `<main>'
        79: from /home/asalgadr/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `eval'
        78: from /home/asalgadr/.rvm/gems/ruby-2.7.1/bin/asciidoctor:23:in `<main>'
        77: from /home/asalgadr/.rvm/gems/ruby-2.7.1/bin/asciidoctor:23:in `load'
        76: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/bin/asciidoctor:15:in `<top (required)>'
        75: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:111:in `invoke!'
        74: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:111:in `each'
        73: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:128:in `block in invoke!'
        72: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `convert_file'
        71: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `open'
        70: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `block in convert_file'
        69: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:118:in `convert'
        68: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:951:in `convert'
        67: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:138:in `convert'
        66: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:214:in `convert_document'
        65: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:596:in `indent_section'
        64: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:267:in `block in convert_document'
        63: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:155:in `traverse'
        62: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:1020:in `content'
        61: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `content'
        60: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `map'
        59: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `block in content'
        58: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:75:in `convert'
        57: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:138:in `convert'
        56: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:586:in `convert_section'
        55: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:155:in `traverse'
        54: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `content'
        53: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `map'
        52: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `block in content'
        51: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:75:in `convert'
        50: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:138:in `convert'
        49: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:586:in `convert_section'
        48: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:155:in `traverse'
        47: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `content'
        46: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `map'
        45: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `block in content'
        44: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:75:in `convert'
        43: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:138:in `convert'
        42: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:2164:in `convert_table'
        41: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:111:in `table'
        40: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:111:in `new'
        39: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:148:in `initialize'
        38: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:656:in `set_row_heights'
        37: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:369:in `row_heights'
        36: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:369:in `each'
        35: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:373:in `block in row_heights'
        34: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell.rb:317:in `height'
        33: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell.rb:309:in `height_ignoring_span'
        32: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell.rb:336:in `content_height'
        31: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell/text.rb:58:in `natural_content_height'
        30: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell/text.rb:92:in `with_font'
        29: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/font.rb:215:in `save_font'
        28: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell/text.rb:99:in `block in with_font'
        27: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-table-0.2.2/lib/prawn/table/cell/text.rb:60:in `block in natural_content_height'
        26: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/box.rb:212:in `render'
        25: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/font.rb:215:in `save_font'
        24: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/box.rb:213:in `block in render'
        23: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/pdf-core-0.7.0/lib/pdf/core/text.rb:214:in `character_spacing'
        22: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/box.rb:214:in `block (2 levels) in render'
        21: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-templates-0.1.2/lib/prawn/text.rb:19:in `text_rendering_mode'
        20: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/box.rb:219:in `block (3 levels) in render'
        19: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/ext/prawn/extensions.rb:265:in `font_size'
        18: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/font.rb:101:in `font_size'
        17: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/box.rb:226:in `block (4 levels) in render'
        16: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb:12:in `wrap'
        15: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/wrap.rb:53:in `wrap'
        14: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:47:in `wrap_line'
        13: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:77:in `apply_font_settings_and_add_fragment_to_line'
        12: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/arranger.rb:166:in `apply_font_settings'
        11: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/pdf-core-0.7.0/lib/pdf/core/text.rb:218:in `character_spacing'
        10: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/arranger.rb:175:in `block in apply_font_settings'
         9: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/arranger.rb:255:in `apply_font_size'
         8: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/ext/prawn/extensions.rb:265:in `font_size'
         7: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/font.rb:101:in `font_size'
         6: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/arranger.rb:255:in `block in apply_font_size'
         5: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:78:in `block in apply_font_settings_and_add_fragment_to_line'
         4: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:93:in `add_fragment_to_line'
         3: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:93:in `each'
         2: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:113:in `block in add_fragment_to_line'
         1: from /home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:226:in `fragment_finished'
/home/asalgadr/.rvm/gems/ruby-2.7.1/gems/prawn-2.2.2/lib/prawn/text/formatted/line_wrap.rb:243:in `update_output_based_on_last_fragment': Prawn::Errors::CannotFit (Prawn::Errors::CannotFit)
Reply | Threaded
Open this post in threaded view
|

Re: Prawn::Errors::CannotFit in Java but not with command line

phgiraud
Hi,
thanks for your answer, that's very useful because I also reproduce with your simple example.
I have identified the version that breaks the generation:

OK with org.asciidoctor:asciidoctorj-pdf:1.5.0-rc.2
KO with org.asciidoctor:asciidoctorj-pdf:1.5.0-rc.3
Reply | Threaded
Open this post in threaded view
|

Re: Prawn::Errors::CannotFit in Java but not with command line

mojavelinux
Administrator
This is a known limitation of using inline images in table cells. You must set the width to a value that will allow the image to fit (or use a block image). Otherwise, it cannot be computed correctly and leads to this error.

This limitation is mentioned in the README. See the 3rd list item here: https://github.com/asciidoctor/asciidoctor-pdf#known-limitations

Best Regards,

-Dan

On Wed, Apr 22, 2020 at 3:30 AM phgiraud [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,
thanks for your answer, that's very useful because I also reproduce with your simple example.
I have identified the version that breaks the generation:

OK with org.asciidoctor:asciidoctorj-pdf:1.5.0-rc.2
KO with org.asciidoctor:asciidoctorj-pdf:1.5.0-rc.3


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Prawn-Errors-CannotFit-in-Java-but-not-with-command-line-tp7938p7940.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Prawn::Errors::CannotFit in Java but not with command line

phgiraud
Thanks for your answer Dan,
I'm replacing inline images with image blocks.

Would it be possible to have more context on the errors, i.e. adoc file and line # ?
Reply | Threaded
Open this post in threaded view
|

Re: Prawn::Errors::CannotFit in Java but not with command line

mojavelinux
Administrator
Unfortunately, adding more context is not possible since this is a bug / restriction coming from deep within Prawn.

Best Regards,

-Dan

On Wed, Apr 22, 2020 at 5:09 AM phgiraud [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks for your answer Dan,
I'm replacing inline images with image blocks.

Would it be possible to have more context on the errors, i.e. adoc file and line # ?


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Prawn-Errors-CannotFit-in-Java-but-not-with-command-line-tp7938p7942.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux