Can FullCalendar be printed to PDF?

John Zabroski picture John Zabroski · Oct 23, 2013 · Viewed 11.2k times · Source

I have tried printing FullCalendar.js rendered calendars to PDF, however none of the generators available seem to work:

  • Aspose PDF does not allow JavaScript, and straight up just doesn't support absolutely positioned elements
  • PrinceXML has known issues where it throws TypeError exceptions when processing JavaScript that are not reproducible in IE, Chrome or Firefox.

My minimal repro example for PrinceXML failure is the examples on Adam Shaw's FullCalendar site. Even when I save the generated HTML (via $("body").html()) and pass the generated HTML to PrinceXML, thus bypassing PrinceXML's incorrect JavaScript handling, PrinceXML doesn't lay out the absolutely positioned events correctly.

What are my options?

Answer

nomatteus picture nomatteus · Oct 24, 2013

Your best bet is probably wkhtmltopdf, which uses the WebKit as the rendering engine. This means you can freely use CSS/Javascript. You might need to look into the javascript-delay option.

I have used wkhtmltopdf successfully in Ruby on Rails, but it appears you are using .NET. A quick search reveals some possible wkhtmltopdf wrapper libraries for .NET:

You may want to take a look at this answer for some alternative solutions.