简体   繁体   中英

Generating a PDF from a HTML page that holds d3js graphs

I'm working on a solution that shows different graphs on a webpage using d3js to draw them. We're now trying to generate a PDF file from the report but can't find a solution that works using our graphs. Is there anyone that has experience with a similar problem and knows a library we can use?

We've been trying these and some others but all have failed to work properly so far:

  • PhantomJs (Doesn't seem to work in Azure)
  • JsPdf (Stylesheets are not shown properly)
  • Rotativa (Best so far but still didn't always work properly)

Thanks, Mark

As this was a application installed on a server, we ended up creating a service that's using CEFsharp to capture the page as a PDF.

Using MSMQ we send a PDF capture request to the service, the service captures the PDF and returns the result through MSMQ. The user will get a notification in the web application that the PDF is ready to be downloaded.

Might not be the solution we hoped for, but an advantage is that users can also schedule PDF's as the service is always running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM