将SVG元素导出为PDF? [英] Export SVG elements to PDF?

查看:1151
本文介绍了将SVG元素导出为PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可视化生成的d3(一个javascript可视化库类似于Protovis或Raphael,使用SVG元素绘制东西)。 vis是交互式的,因此用户可以与其进行交互和编辑。一旦用户对他/她的可视化感到满意,我希望用户能够将该可视化作为PDF导出。我试过几个HTML到PDF库,他们不使用SVG元素。



没有问题,如果解决方案是客户端或服务器端。我使用PHP服务器端,但Python或Java实现也可以工作。



浏览器支持:理想情况下,它将支持所有现代浏览器,但最低程度,我想支持最新版本的Firefox和webkit浏览器。

解决方案

我不知道客户端有任何强大的PDF库。 p>

一个快速可能的方法是将svg内容发送到服务器,并使用batik for java将svg转换为pdf,然后再次将响应发送给客户端。



这里是一个相关的 SO for the converstion


I have a visualization generated by d3 (a javascript visualization library similar to Protovis or Raphael, which draws stuff using SVG elements). The vis is interactive, so the user can interact with and edit it. Once the user is satisfied with his/her visualization, I would like the user to be able to export this visualization as a PDF. I've tried several HTML to PDF libraries and they don't work with SVG elements.

It is okay if the solution is either client side or server side. I'm using PHP server side but Python or Java implementations might also work.

Browser support: Ideally it would support all modern browsers, but minimally I'd like to support latest versions of both Firefox and webkit browsers.

解决方案

I do not know of any strong PDF libraries on the client side.

A quick possible way would be to send the svg content to a server, and use something like batik for java to turn the svg to pdf and then send the response to the client again.

Here is a related SO for the converstion.

这篇关于将SVG元素导出为PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆