Export web application to pdf using server-side render

Our web application(many d3 charts) is set up by vue, and I could export our

webpage to pdf by the combination of canvg, html2canvas(convert web content to

png) and emit png file to server and use nodejs to download it automatically

and periodically(weekly report).

However, I was asked to use different render method from client-side to

server side rendering and use wkhtmltopdf or phantomjs to download pdf.

My question is that is it difficult to render many complicated d3 chart and edit

css in server side rendering by using vue or another technique?


SVG DOM elements can be convert into different images format using server side rendering option. Apache Batik such a library to convert SVG DOM elements into pdf,png,jpg,word.

Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes, such as display, generation or manipulation.
The project’s ambition is to give developers a set of core modules that can be used together or individually to support specific SVG solutions. Examples of modules are the SVG Parser, the SVG Generator and the SVG DOM. Another ambition for the Batik project is to make it highly extensible —for example, Batik allows the developer to handle custom SVG elements. Even though the goal of the project is to provide a set of core modules, one of the deliverables is a full fledged SVG browser implementation which validates the various modules and their inter-operability.

The wkhtmltopdf is a popular library for converting complex html content to pdf.

You don’t have to worry about your complicated d3 chart or css. It will handle it. But you have to install wkhtmltopdf command line tool on your system.