QuestPDF
QuestPDF copied to clipboard
Image inside svg
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:
The expected result should be a PDF file with the image, as shown below:
Environment I'm using the latest version of the library on Windows 11 x64
Thank´s
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?
@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
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
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.
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.
I have opened your SVG in Affinity Designer and resaved it. After this operation, Chrome shows the file correctly. Please try it:
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!
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.
Thanks for explanation. And are you planning to add support to use PDF images as a background in QuestPDF? That would be helpful.
Could you please elaborate a bit more about that feature?
Hi, I'm also facing same issue. I simply want to add an image as Page Background. Is there a direct way for this?
This is already possible using layers. For example:
page.Content()
.Layers(layers =>
{
// layer below main content
layers
.Layer()
.Image("path/to/image.png");
layers
.PrimaryLayer()
.Text("Your content goes here");
});
@girlpunk Thank you so much for answering this question.
Since there has been no recent activity, I’m closing this issue. If you experience a similar problem or have a related request, feel free to open a new GitHub issue. I appreciate your feedback! ❤️