Why are my SVG images not compiled properly into pdf?

I have an SVG image (attached), created in python using your standard matplotlib.pyplot, with thin blue lines and blue dots. When I place the image in the typst document using figure(image(“.svg”)), it is rendered correctly in the preview, but not in the output pdf, see below the first figure. (First image: original svg figure, 2nd is a screenshot of the output pdf) Is this a known issue, and if so, is there a workaround to make the svg work? (Other than to save to png, which does work of course, but misses the good properties of svg images) I’m using typst 0.13.
gamma05|0x0

gamma05_pdf_output

Hello. Are you sure you’ve attached the SVG image?

I was 99% sure I did it, but I think I did accidentally upload the png, I’ve now edited the original post with the actual svg file!

In Okular 24.12.3 and Typst 0.13.1 the output is the same as in SVG.

Close-up

Okay. For me with the default ubuntu Document viewer, and on Firefox the output using the svg looks like the second image I posted still. I’m compiling the pdf through vscode, that is, I’m not using the web environment, if that’s of any help.

This is just how renderer renders all the small objects at that scale. It looks much better close-up.

Firefox close-up

I don’t know what those 2 programs use for rendering, but if it looks the same, then it might be the same library, in which case you can open an issue, maybe they can improve how it looks.

Hi @vrikala, I have moved your question to the Questions category, please make sure to check the category when creating a topic :slight_smile: that also means that you can select an answer. If you feel the response you got has sufficiently answered your question, be sure to give it a checkmark. This will help others find the solution in the future. Thanks!

1 Like

Zooming in on the pdf using either firefox or Document viewer, I do get the same close-up as you do, and when using Okular the pdf with the svg image is rendered completely fine, even without zooming. So it’s an issue with the other pdf viewers (also on browsers on Windows it seems). Thanks in anycase! I will probably have to resort to high-resolution png files, as those are rendered correctly on any pdf viewer.

1 Like