Wkhtmltopdf not generating my ReactJs App

1,160 views
Skip to first unread message

marlon...@dalmark.com.br

unread,
May 17, 2016, 2:54:56 PM5/17/16
to wkhtmltopdf General
Hi all, 

I am using 0.12.2.1 (with patched qt) version and when I try to generate a PDF from my React App with the option --debug-javascript the following message is returned:

desenv01@desenv01-PC:~$ wkhtmltopdf --debug-javascript  http://localhost:3000/report/1 react-report.pdf
Loading pages (1/6)
Warning: undefined:0 TypeError: 'undefined' is not a function     
Warning: undefined:0 TypeError: 'undefined' is not an object
Warning: undefined:0 TypeError: 'undefined' is not an object
Warning: undefined:0 ReferenceError: Can't find variable: React
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done

Then when I go see the pdf, nothing is generated.

So, I tried to use the version 0.13alpha and it seems to work nicely with ReactJs. It renders the information respecting the CSS for media print. However, I have a table which has a thead and tbody with several rows. When my PDF has more than 1 page, the thead is not being repeated on every page, only on the first one.
The following CSS properties are being set on thead, tbody and th:

thead { display: table-header-group !important; }
  tfoot { display: table-row-group }
  tbody { display: table-row-group }
  tr {
    page-break-inside: avoid !important;
    position: relative;
   }

This behaviour seems only to happen in version 0.13alpha. Even with a simple page (with no ReactJs), in version 0.13alpha, the thead does not repeat, but in version 0.12.2.1 it works fine.
BTW, I tested on Ubuntu 14.01 and CentOS release 6.7 (Final).

I hope I was clear enough to explain my problem.. :D

marlon...@dalmark.com.br

unread,
May 18, 2016, 12:42:55 PM5/18/16
to wkhtmltopdf General
I figured out my error!
I need a polyfill to make wkhtmltopdf recognize my ReactJs code, see facebook/react#3609
Reply all
Reply to author
Forward
0 new messages