Free Support Forum - aspose.com

ConvertSVG takes 20 seconds to create a one page pdf

We need to create a pdf based on a SVG file.
Goal is the keep the text from the svg file searchable/selectable in the pdf.

The following code converts a svg file to a pdf and it takes 20 seconds for a simple one page pdf to create.
The svg image use in the example is attached to this issue.

What is the reason for this bad performance?
Is there any faster way to create a pdf based on a svg while keeping the text in the pdf selectable?

      private static void ConvertSvgToPdfTest()
        {
      
            using (MemoryStream msSvg = new MemoryStream(System.IO.File.ReadAllBytes(@"C:\temp\qrbill.svg")))
            {
                using (var document = new Aspose.Html.Dom.Svg.SVGDocument(msSvg, ""))
                {
                    // Initialize PdfSaveOptions.
                    // Set A5 as a page-size and change the background color to green
                    var options = new Aspose.Html.Saving.PdfSaveOptions()
                    {
                        PageSetup =
                        {
                            AnyPage = new Aspose.Html.Drawing.Page()
                            {
                                Size = new Aspose.Html.Drawing.Size(Aspose.Html.Drawing.Length.FromCentimeters(21.0f),
                                    Aspose.Html.Drawing.Length.FromCentimeters(29.7f)),
                                Margin = new Margin(50, 670,0,0)
                            }
                        }
                    };

                    var tmp = Path.GetTempPath() + Path.DirectorySeparatorChar + new Random().Next();
                    // Convert HTML to PDF
                    Stopwatch sw = Stopwatch.StartNew();
                    Aspose.Html.Converters.Converter.ConvertSVG(document, options, tmp);
                    Console.WriteLine(sw.ElapsedMilliseconds);

                }
            }

        }

qrbill.zip (4.2 KB)

@manuelk

We tested the scenario in our environment with Aspose.HTML for .NET 20.7 and noticed that API took 15 seconds. However, we have logged an investigation ticket as HTMLNET-2761 in our issue tracking system to investigate the case further. We will inform you as soon as the ticket is resolved. Please spare us some time.

We are sorry for the inconvenience.

Just a note: You do have a website where i can convert the svg to a pdf and it works fast and without any problem


I just like to be able to do the same

Note: I was actually wrong with my assumption. The website only instantly shows 100%, but it also takes forever to convert this svg to a pdf

@manuelk

We will surely analyse the earlier logged ticket and investigate on how can the conversion become more faster. We will let you know as soon as the ticket is resolved.