Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotly.Net generated SVGs misinterpreted #909

Open
jaguarxii opened this issue May 30, 2024 · 3 comments
Open

Plotly.Net generated SVGs misinterpreted #909

jaguarxii opened this issue May 30, 2024 · 3 comments

Comments

@jaguarxii
Copy link

jaguarxii commented May 30, 2024

Describe the bug
Some SVGs generated from Plotly.Net that contain "newline" in text are misinterpreted.

To Reproduce
Using the following samples
simple_pie_20240530_1149

simple_bar_20240530_1149

after embeding to a document:

    column.Item().Border(2, Unit.Mil).Padding(2, Unit.Millimetre)
        .AlignCenter()
        .Width(150, Unit.Millimetre)
        .Svg(svgBarChart)
        ;

    column.Item().Border(2, Unit.Mil).Padding(2, Unit.Millimetre)
        .AlignCenter()
        .Width(100, Unit.Millimetre)
        .Svg(svgPieChart)
        ;

the images should mantain its structure, but the labels are not quite right

image

Expected behavior
image

I have found that the tags that include "em" untis, are misinterpreted

<tspan class="line" dy="0em" x="250" y="250">Simple</tspan>
<tspan class="line" dy="1.3em" x="250" y="250">pie chart</tspan>

image

If I change them by removing its units I get the right result:

<tspan class="line" dy="0em" x="250" y="250">Simple</tspan>
<tspan class="line" dy="50" x="250" y="250">pie chart</tspan>

image

Environment
QuestPDF 2024.3.10
Window 11 / Debian 12
dotnet 8

Aditional
Also, the font described in the chart "Nunnito" is not embeded in the file, as it was described in the issue #777

@MarcinZiabek
Copy link
Member

This behavior could be:

  • a corner case not supported by the Skia SVG engine,
  • an option invalid in the SVG specification and therefore not supported by the Skia SVG engine, but correctly displayed in web browsers as they have less strict rules.

I am unable to check as the W3C SVG validator is not working at this moment.

@jaguarxii
Copy link
Author

jaguarxii commented Jun 1, 2024

Hi, indeed it seems that relative units (em) are not quite supported by Skia SVG.

Using the Example Units SVG from the W3 SVG Recommendation, that should look like this:

image

After embedding into my test PDF document, looks like this:

image

@MarcinZiabek
Copy link
Member

Thank you for checking this behavior. Although Skia SVG is quite a mature engine, it surely does not support every feature. SVG is just a surprisingly complex standard 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants