asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.15k stars 500 forks source link

Table's width was set larger than its contents' maximum width (max width 498.79950119999995, requested 498.79999999999995) Use --trace for backtrace #1835

Closed cer closed 3 years ago

cer commented 3 years ago

Asciidoctor PDF 1.5.3 using Asciidoctor 1.5.7.1 [https://asciidoctor.org]

[cols="3"]
|===

3+| X

3+| Y

| Z
2+| Q

|===
/Users/cer/.rvm/gems/ruby-2.4.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:336:in `column_widths': Table's width was set larger than its contents' maximum width (max width 498.79950119999995, requested 498.79999999999995) (Prawn::Errors::CannotFit)
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:647:in `set_column_widths'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:147:in `initialize'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:111:in `new'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/prawn-table-0.2.2/lib/prawn/table.rb:111:in `table'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:2164:in `convert_table'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:138:in `convert'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/abstract_block.rb:71:in `convert'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/abstract_block.rb:80:in `block in content'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/abstract_block.rb:80:in `map'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/abstract_block.rb:80:in `content'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/document.rb:1209:in `content'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:155:in `traverse'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:267:in `block in convert_document'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:596:in `indent_section'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:214:in `convert_document'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/lib/asciidoctor/pdf/converter.rb:138:in `convert'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/document.rb:1141:in `convert'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor.rb:1515:in `convert'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor.rb:1589:in `block in convert_file'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor.rb:1589:in `open'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor.rb:1589:in `convert_file'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/cli/invoker.rb:129:in `block in invoke!'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/cli/invoker.rb:112:in `each'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-1.5.7.1/lib/asciidoctor/cli/invoker.rb:112:in `invoke!'
    from /Users/cer/.rvm/gems/ruby-2.4.1/gems/asciidoctor-pdf-1.5.3/bin/asciidoctor-pdf:27:in `<top (required)>'
    from /Users/cer/.rvm/gems/ruby-2.4.1/bin/asciidoctor-pdf:23:in `load'
    from /Users/cer/.rvm/gems/ruby-2.4.1/bin/asciidoctor-pdf:23:in `<main>'
    from /Users/cer/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
    from /Users/cer/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
mojavelinux commented 3 years ago

The prawn-table gem is doing some very careless math. As a result, the sum of the cells ends up being greater than the width it allocates for them in certain circumstances. I may be able to patch it to work around this issue.

mojavelinux commented 3 years ago

The condition that triggers this is when two or more rows have cells that span a different number of columns.

mojavelinux commented 3 years ago

Asciidoctor 1.5.7.1

As an aside, I strongly recommend that you upgrade to Asciidoctor 2. The Asciidoctor 1.5.x series is no longer actively maintained.

mojavelinux commented 3 years ago

I'm going to backport this change to the v1.5.x branch for when/if I release 1.5.4.