ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
448 stars 92 forks source link

Unable to layout item: JSHandle@node when cells have significant size #267

Open rohel01 opened 4 years ago

rohel01 commented 4 years ago

Hello,

I use the following on an up to date Ubuntu 19.10

The install log of asciidoctor-web-pdf was :

install.log

If I try to generate example.txt, I get this errors:

mmelchiore:doc$ asciidoctor-pdf example.adoc Unable to layout item: JSHandle@node Unable to find destination _a_section while generating PDF outline! This likely happened because an anchor link contained an > umlaut (https://bugs.chromium.org/p/chromium/issues/detail?id=985254).

I have done a bit of testing, and if you comment the last "Lorem...", the error goes away. So I guess something is up with the layout of big cells...

ggrossetie commented 4 years ago

Paged.js has updated the logic to avoid infinite loop so now when the "layouter" cannot fit an element into the page, this element is left on the "invisible" column (on the right).

If you open the developer tools on the HTML page, you can see the table on the right:

right-column

And apparently Paged.js does not know how to break a cell but that's not an easy task! I will open an issue upstream with your example.

rohel01 commented 4 years ago

Automatically breaking up the cells is the full feature required to fix my issue. I understand this requires much more work so I think we should aim for a shorter term workaround.

Diagnostic messages would help the author manually break up the cells. Currently, I only see a cryptic error with no information on the elements causing the problems.... and the document can be quite long...

FYI, asciidoctor-pdf does not implement automatic cell break on page boundaries either. This is something I need to manually fix, which is a pity since it is dependent on the currently active template

ggrossetie commented 4 years ago

Diagnostic messages would help the author manually break up the cells. Currently, I only see a cryptic error with no information on the elements causing the problems.... and the document can be quite long...

The error is a bit better on the developer console:

warn

I believe that our logger cannot create a string representation of a Node that's why we get JSHandle@node instead of <tr ...>. Do you think that would be enough to troubleshoot? If not, what information should we add? Maybe the page number?

Unable to layout <tr> element on page 2

FYI, asciidoctor-pdf does not implement automatic cell break on page boundaries either. This is something I need to manually fix, which is a pity since it is dependent on the currently active template

It should be possible to do it with Paged.js but as mentioned there are a few things to consider.

rohel01 commented 4 years ago

We need to consider the target user profile, when troubleshooting:

ggrossetie commented 4 years ago

We need to consider the target user profile, when troubleshooting: End-users We cannot expect them to know about the intermediate HTML code, it is an implementation details. Further, using chromium with the development console is burdensome and requires advanced skills. This is why logging is important for them. Here is the Cursor interface, which AsciidoctorJ uses to trace source location throughout the compilation pipeline.

That's a good idea but it probably won't be easy to infer the line number in the AsciiDoc document from the Paged.js error.

Hackers I don't miond using chromium and the development console to troubbleshoot. But, I am not familiar with those technlogies. Maybe, we should provide a debugging procedure ?

Yes that's a good idea. We can start by adding documentation and improving the error messages. Feel free to suggest improvements and/or open pull request to update the documentation.

Here's the upstream issue for the table issue: https://gitlab.pagedmedia.org/tools/pagedjs/issues/227 Actually, there are several issues depending on which styles are applied to the table but even when using an unstyled table Paged.js does not chunk the table properly and some cells/columns are missing.

I will look into the "Unable to find destination _a_section while generating PDF outline!" issue.

ggrossetie commented 4 years ago

I will look into the "Unable to find destination _a_section while generating PDF outline!" issue.

It's related to the table bug, the PDF generated (by Chrome) does not contain the Dest entry for "_a_section".

albertosantini commented 4 years ago

Also it happens when the table is very long and one page is not enough. It gives Unable to layout item: JSHandle@node for the element between the two pages.

As workaround I need to split the table and to fit manually the table "children" in different pages.

ggrossetie commented 2 years ago

I'm moving @dgslos comment here since it's related:

I'm still getting this error. Downloaded the v1.0.0-alpha.14 release. Tried both linux and windows versions

Error:
Unable to layout item:  JSHandle@node
Unable to find destination _overview_size_of_the_subcollection_mostly_by_year_if_database_in_access while generating PDF > outline! This likely happened because an anchor link contained an umlaut (https://bugs.chromium.org/p/chromium/issues/detail?id=985254).
Unable to find destination _additional_questions while generating PDF outline! This likely happened because an anchor link  contained an umlaut (https://bugs.chromium.org/p/chromium/issues/detail?id=985254).
Unable to find destination _possible_improvements while generating PDF outline! This likely happened because an anchor link > contained an umlaut (https://bugs.chromium.org/p/chromium/issues/detail?id=985254).

https://github.com/Mogztter/asciidoctor-web-pdf/issues/340#issuecomment-978167274

I will open a pull request to remove the message:

This likely happened because an anchor link contained an umlaut (https://bugs.chromium.org/p/chromium/issues/detail?id=985254).

This message is misleading and the error is now fixed. I think we should replace it by:

This likely happened because Paged.js was unable to layout a portion of your document (i.e., missing from the output). It can happen when using tables that don't fit on one page.

What do you think?