Unable to display graphics using Wicked PDF

I am trying to make an HTML page in PDF using wicked_PDF. The page contains several diagrams that I create using D3.js. Only axis of diagrams are visible in PDF. The chart body is empty. I tried to convert SVG to both canvas and PNG image (encoded using Base64). In both cases, images are displayed as HTML, but only the axes are shown in PDF. Any suggestions?

+4
source share
2 answers

Javascript does not seem to work before rendering PDF.

First, make sure it is enabled when rendering a PDF. According to the link , there is an option :disable_javascript => false to render :pdf .

Then all assets should be included with absolute URLs. According to the same link,

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

+1
source

It seems that the graph is not fully displayed, but wickedpdf anchors the page between them. Thus, you can use the option to wait for the java script to finish and display the graph.

: javascript_delay => 10000

now wicked pdf will wait 10 seconds.

Note. This will only work for version 0.12.1 of wkhtmltopdf.

0
source

Source: https://habr.com/ru/post/1496395/


All Articles