Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to render charts using Wicked PDF

I'm trying to render an HTML page to PDF using wicked_PDF. The page contains several charts that I create using D3.js. On the PDF, only the axes of the charts are visible. The body of the chart is blank. I tried to convert the SVG to both a Canvas and a PNG image (encoded using Base64). IN both cases, the images display as HTML, but only the axes are shown in the PDF. Any suggestions?

like image 593
user1742188 Avatar asked Nov 01 '22 16:11

user1742188


1 Answers

Is seems that javascript does not work before rendering PDF.

First, be sure that it is enabled on rendering PDF. According to link, there exists option :disable_javascript => false to render :pdf.

Next, all assets must be included with absolute urls. According to the same link,

You must define absolute paths to CSS files, images, and javascripts; the best option is to use the wicked_pdf_stylesheet_link_tag, wicked_pdf_image_tag, and wicked_pdf_javascript_include_tag helpers.

like image 194
Alex Teut Avatar answered Nov 10 '22 04:11

Alex Teut