gpt4 book ai didi

javascript - 如何将 SVG 图导出为 pdf

转载 作者:行者123 更新时间:2023-11-28 01:28:22 24 4
gpt4 key购买 nike

我正在使用 API它在 SVG 中呈现折线图,但我无法像在 HTML5 Canvas 中呈现的其他图形一样将其导出为 PDF

$(function() {
// let's loop to build tooltips and x labels.
var thelabels = new Array(30);
for (var i = 0; i < 30; i++) {
thelabels[i] = (i % 6 === 0) ? (i + 1) + " september" : "";
}

// build the chart using the "google analytics" template.
$("#chart").chart({
template: "raphael_analytics",
labels: thelabels,
values: values()
});

// start a loop that sets new data in the chart every 5 seconds.

});

代码在 jsfiddle 中可用

在搜索时我得到了一个链接,我可以在其中将 SVG 图形导出为 PDF,但他们提供的演示不起作用,他们使用 Perl 脚本导出。

我想从客户端/浏览器导出到 Canvas 图像数据

已编辑


我在github 又看到了一个库它允许您从客户端将 SVG 下载为 PDF。但是在库中,他们使用了一个名为 "RGBColor(fillColor)" 的对象,这会抛出一个错误,如 RGBColor is not defined 那么是否有任何我需要包含的库......???

最佳答案

我不得不将图表和饼图转换为 pdf 并最终使用这个第三方包。它将 HTML 转换为 PDF。只需渲染图形,然后将 URL 传递给转换器。效果很好。它叫做HiQPDf

关于javascript - 如何将 SVG 图导出为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31204821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com