简体   繁体   中英

IText c# SVG to PDF not fully displayed

I would like to use iText to convert an SVG file into a PDF file. However, the Pdf file is created incorrectly. It is displayed in the wrong format. What do I have to do to solve this problem?

Here the C# code:

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:

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

and here the result:

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

@enxaneta I added viewBox="-283 0 1195 1289" to the SVG-File. Now it works. Thank you very much!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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