7

I want to make PDF rendering of my big report table. But it seems that phantomjs doesn't support the rowSpan attribute. Here is the example:

phantomjs rasterize.js "http://fiddle.jshell.net/eric777/SLtGa/show/" report.pdf A4

Here is the jsfiddle

And here is the result [

Is there workaround for this?

EDIT:

Maybe somebody could be fix this issue in webkit?

Erik
  • 14,060
  • 49
  • 132
  • 218

1 Answers1

11

2018 Update

As of March 2018, PhantomJS development has been suspended with the recommendation to use headless Chrome instead. While it appears that WebKit, and therefore Safari, still has this problem, Chrome, including headless Chrome, now splits the table cleanly into 2 pages.

Page split from Opera browser, based on Chrome


Original post

This is not a bug in phantomjs, this is how the WebKit handles page breaks. (Chrome, too.) You can see this by opening the page in Safari and then trying to print it on "US Letter" size. I don't know why you get 3 pages on A4 size when your fiddle fits into 2 pages of (shorter) US Letter size, but I think that is beside the point.

In general all HTML to PDF converters that I am aware of have this exact same problem or have such difficulty solving it that they are considered unacceptably buggy. See How to avoid page break inside table row for wkhtmltopdf for example.

See some ways to use JavaScript to help WebKit break up the table better here, along with more discussion of the problem.

Community
  • 1
  • 1
Old Pro
  • 24,624
  • 7
  • 58
  • 106
  • Unfortunately that don't work for me. It's seems webkit developers think that page printing is not main thing :( – Erik May 11 '13 at 22:28
  • That works fine in Opera. Yes sure, I've give the bounty I just want to find workaround that will work for me. May be anybody else can help. – Erik May 12 '13 at 07:26
  • 1
    @Erik you need to explain your restrictions if you want to get a workaround that you can use. Breaking up the table using JavaScript is probably the easiest thing to do. You could also break up the table in some server-side language or, even better, directly export the data into PDF using some server-side PDF library. But I can't give you any more direction without more information – Old Pro May 12 '13 at 07:30
  • all I need is render my html code into pdf by using phantomjs . JavaScript is not solution for me, so I want to find better. Can you provide information about that it's webkit bug? issue tracker, oficial answer from webkit developer? – Erik May 12 '13 at 07:44
  • 2
    @Erik do you read the links I provided above? They include links to [this patch](https://qt.gitorious.org/~trvrnrth/qt/trvrnrths-qt/commits/4.8.4) to Qt to fix the problem in WebKit. You can also see WebKit bugs [35217](https://bugs.webkit.org/show_bug.cgi?id=35217),[39733](https://bugs.webkit.org/show_bug.cgi?id=39733), [59597](https://bugs.webkit.org/show_bug.cgi?id=59597), and [89756](https://bugs.webkit.org/show_bug.cgi?id=89756). See also PhantomJS bug [10638](https://github.com/ariya/phantomjs/issues/10638) – Old Pro May 12 '13 at 18:10