如何在 Windows 上以编程方式将 SVG 转换为 PDF?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1048205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:32:05  来源:igfitidea点击:

How to programmatically convert SVG to PDF on Windows?

windowspdfpdf-generationsvg

提问by Matthew Lock

I'm looking to programmatically convert SVG to PDF documents on a server. What are my options for doing that on Windows?

我希望在服务器上以编程方式将 SVG 转换为 PDF 文档。在 Windows 上执行此操作有哪些选择?

I've seen links to Inkscape, Batik, and svg2pdf, but I'm not sure if these can easily be automated to perform the conversion on a Windows server.

我已经看到了InkscapeBatiksvg2pdf 的链接,但我不确定这些链接是否可以轻松自动化以在 Windows 服务器上执行转换。

There's an unusual solution here which involves automating OpenOffice Portable on the server: http://www.codeproject.com/KB/office/PortableOpenOffice.aspx

这里有一个不寻常的解决方案,它涉及在服务器上自动化 OpenOffice Portable:http: //www.codeproject.com/KB/office/PortableOpenOffice.aspx

采纳答案by Aaron Digulla

There are two options:

有两种选择:

Batik will give you more control. With Inkscape, you can use the command line parameters (--export-pdf IIRC) to do the conversion without firing up the UI.

蜡染会给你更多的控制。使用 Inkscape,您可以使用命令行参数 (--export-pdf IIRC) 进行转换而无需启动 UI。

回答by r?ph

Take a look at the Apache Batik Toolkit. The rasterizercan convert svg to images or pdf (It's a java tool).

查看 Apache Batik 工具包。该光栅可以SVG转换为图片或PDF(这是一个java工具)。

The SVG Rasterizer is a utility that can convert SVG files to a raster format. The tool can convert individual files or sets of files, making it easy to convert entire directories of SVG files. The provided formats are JPEG, PNG and TIFF, however the design allows new formats to be added easily. In addition, the rasterizer can (despite its name) transcode to PDF.

SVG Rasterizer 是一个实用程序,可以将 SVG 文件转换为光栅格式。该工具可以转换单个文件或文件集,从而可以轻松转换整个 SVG 文件目录。提供的格式为 JPEG、PNG 和 TIFF,但该设计允许轻松添加新格式。此外,光栅化器可以(不管它的名字)转码为 PDF。

回答by Vincent Buck

It does not come free, but PrinceXMLdoes a very good job with SVG.

它不是免费的,但PrinceXML在 SVG方面做得非常好。

回答by arcanum

You can probably use Cairoand librsvgto read SVG into Cairo surface and export to PDF using Cairo. There are many bindings for languages and these are open source libraries.

您可能可以使用Cairolibrsvg将 SVG 读入 Cairo 表面并使用 Cairo 导出为 PDF。有许多语言绑定,这些都是开源库。

回答by Jason

You can use altsoft xml2pdf serverfor this

您可以使用altsoft xml2pdf服务器

回答by dertkw

you might want to look into Apache FOP.
Check out the part about graphic formats.

你可能想看看Apache FOP
查看有关图形格式的部分。