QuestPDF / QuestPDF

QuestPDF is a modern open-source .NET library for PDF document generation. Offering comprehensive layout engine powered by concise and discoverable C# Fluent API. Easily generate PDF reports, invoices, exports, etc.

Home Page:https://www.questpdf.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Showing an svg image spams the log

Krm1t opened this issue · comments

Hey

Describe the bug
We've upgraded to version 2024.3.2 to take advantage of the changed svg support but now our log is getting spammed with the message cannot append child nodes to an SVG shape.
The message doesn't seem to be logged with the regular ILogger as there is no log level or anything so i'm guessing something like Console.WriteLine().
It looks like i get one log per image and depending on which template we run that amounts to an avg of 50 logs per document.

To Reproduce
I've used the following code to load and show the image.
Certain things omitted to keep it short.
If need be i can try and create a test application to reproduce this.
Also i've attached one of the images that this happens with.

using var streamReader = new StreamReader(resourceStream);
var svgcontent = streamReader.ReadToEnd();
 table
  .Cell()
  .Row(rowNumber)
  .Column(2)
  .AlignCenter()
  .Height(_rowHeight)
  .AlignMiddle()
  .Svg(svgContent)
  .FitArea();

Expected behavior
I'm not sure what the expected behavior should be but i can say this, as i'm not the one doing anything to the image i must assume that this happens somewhere in the belly of QuestPDF but as i have no way of fixing the issue then the message really is just useless noise.
So maybe not show it at all or at the very least use an ILogger so i can filter it out.

checkbox-checked

Indeed, those messages are produced by the native Skia code. In contrast to web browsers, the Skia SVG rendering engine is quite strict regarding the specification.

Would you please share your SVG image? Maybe there is something wrong with your file?

@MarcinZiabek I actually attached the image. I just hadn't removed the ! in front of it so the text wasn't showing :)

Thanks for taking the time.

I tried removing the 2 symbols but it didn't help.
Fiddling around with it a bit i found that having <path d="..."></path> is not allowed so changing it to <path d="..." />

I'll leave this here in case someone happens upon it.

And again thanks @MarcinZiabek