简体   繁体   English

IText c# SVG 到 PDF 未完全显示

[英]IText c# SVG to PDF not fully displayed

I would like to use iText to convert an SVG file into a PDF file.我想使用 iText 将 SVG 文件转换为 PDF 文件。 However, the Pdf file is created incorrectly.但是,Pdf 文件创建不正确。 It is displayed in the wrong format.它以错误的格式显示。 What do I have to do to solve this problem?我该怎么做才能解决这个问题?

Here the C# code:这里的 C# 代码:

using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Drawing.Imaging;
using iText;
using iText.Svg.Converter;
using iText.Kernel.Pdf;
using iText.Kernel.Utils;




namespace SvgToPdf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FileStream svgPath = File.Open("1/1.svg", FileMode.Open);
            FileStream pdfPath = File.Create("autput.pdf");
            SvgConverter.CreatePdf(svgPath, pdfPath);
        }
    
    }
}

This is what the svg file looks like:这是 svg 文件的样子:

http://jakob-ofner.myds.me/svg/1.svg http://jakob-ofner.myds.me/svg/1.svg

and here the result:结果如下:

http://jakob-ofner.myds.me/svg/1.pdf http://jakob-ofner.myds.me/svg/1.pdf

@enxaneta I added viewBox="-283 0 1195 1289" to the SVG-File. @enxaneta 我将viewBox="-283 0 1195 1289"添加到 SVG 文件中。 Now it works.现在它起作用了。 Thank you very much!非常感谢!

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

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