简体   繁体   English

如何在 C# 中将 SVG 转换为 PDF?

[英]How do I convert an SVG to PDF in C#?

How can I set a cookie at ABCpdf12 in this code?如何在此代码中在 ABCpdf12 设置 cookie?

string url = "";

Doc theDoc = new Doc();
theDoc.Read(url);
theDoc.Save("document.pdf");
theDoc.Clear();

Big thanks!非常感谢!

I've already solved the problem.我已经解决了这个问题。 I downloaded the svg with selenium and used iText7 to generate the PDF-file.我下载了 svg 和 selenium 并使用 iText7 生成 PDF 文件。

I used itext7 , which I've installed as NuGet-packet.我使用了 itext7 ,它已作为 NuGet-packet 安装。

using iText;
using iText.Svg.Converter;

and here the code:这里是代码:

FileStream svgPath = File.Open("input.svg", FileMode.Open);
FileStream pdfPath = File.Create("output.pdf");
SvgConverter.CreatePdf(svgPath, pdfPath);

To avoid errors, you should set the current location equal to the location of the svg file.为避免错误,您应将当前位置设置为等于 svg 文件的位置。 ( Directory.SetCurrentDirectory() ) ( Directory.SetCurrentDirectory() )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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