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

Image inside svg #903

Open
borgues opened this issue May 22, 2024 · 9 comments
Open

Image inside svg #903

borgues opened this issue May 22, 2024 · 9 comments

Comments

@borgues
Copy link

borgues commented May 22, 2024

Eu tenho uma imagem em svg que contém uma imagem em base 64 como background. Essa imagem será inserido no pdf ocupando todo a página. O svg é carregado, mas a imagem de fundo que esta dentro do svg não é carregado, dado a seguinte mensagem: can't render image: load image failed

Thats is the svg file:

Teste

The expected result should be a PDF file with the image, as shown below:

image

Environment
I'm using the latest version of the library on Windows 11 x64

Thank´s

@MarcinZiabek
Copy link
Member

Thank you for sharing this issue 😄

I have investigated the bug, and it should be fixed in the 2024.3.10 release. Could you please give it a try?

@lukasvecerka23
Copy link

@MarcinZiabek Hello, we're facing similar issue. We have SVG which contains png images. When I use the image in PDF I can see everything from the SVG except the images. Do you know what could be problem?

.NET version: .NET Framework 4.7.2
QuestPDF version: 2024.6.4

Thanks

@MarcinZiabek
Copy link
Member

Could you please share the SVG file with me?
Is the image embedded or provided as a path to local storage?
Could you please validate your SVG file against the official specification? https://validator.w3.org

@lukasvecerka23
Copy link

Yes, here is the SVG file together with generated PDF.

It seems that some of the embedded pngs are generated but some of them not.

I tried to validate the SVG using provided validator but I'm getting 429 Too Many Requests.

background2

test.pdf

@MarcinZiabek
Copy link
Member

When I open your SVG file in Safar or Chrome, specific images are also not visible. It seems that your SVG file may contain issues that only some SVG parsers can handle.

image

I have opened your SVG in Affinity Designer and resaved it. After this operation, Chrome shows the file correctly. Please try it:

fixed.svg.zip

@lukasvecerka23
Copy link

Yeah now it works. The original SVG was converted from PDF so perhaps the converter doesn't work correctly. Do you have any idea how could be PDF vectors converted to SVG easily?

Thanks for help!

@MarcinZiabek
Copy link
Member

It's not easy... PDF does not support embedding SVG files. QuestPDF (through the Skia library) translates SVG contents into PDF drawing commands. So, the opposite process must be equally difficult: analyze every drawing command and find the nearest feature from SVG. It is wholly expected to produce not-perfect results.

@lukasvecerka23
Copy link

Thanks for explanation. And are you planning to add support to use PDF images as a background in QuestPDF? That would be helpful.

@MarcinZiabek
Copy link
Member

Could you please elaborate a bit more about that feature?

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

3 participants