We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Transparent background for an SVG stored in a PDF

I am trying to add an SVG to a pdf as an Annotation

    public static byte[] AddSvg(byte[] documentBytes, string svg,int page, double llx, double lly, double urx, double ury)
    {
        SetLicense();
        using (var documentStream = new MemoryStream(documentBytes))
        {
            using (var document = new Document(documentStream))
            {
                var stamp = new StampAnnotation(document.Pages[page], new Rectangle(llx, lly,urx, ury))
                            {
                                Image = new MemoryStream(svg.ToByteArray())
                            };
                

                document.Pages[page].Annotations.Add(stamp);
                var outputStream = new MemoryStream();
                document.Save(outputStream);
                return outputStream.ToArray();
            }
        }
    }

One requirement is to have the Image background to be transparent.
Because the Image is a Memory Stream, I am left uncertian as to how to set it’s background color to Transparent.
I have tried within the SVG xml, but that does not work.

@gmitchell.ipipeline

Can you please share input SVG file and expected output file. Please explain the requirements in more detail if you want to manipulate the SVG file or need to make some changes in the PDF file?

examples.zip (2.8 MB)
In the original.pdf you can see the text at the top “Check Box Export Value Default Yes”
In the PDF with the SVG in question, the “Check Box” text is completely covered by the SVG image.
We want the annotation to be transparent, so that the text underneath is still visible where the has no text or lines.

@gmitchell.ipipeline

It depends on the background of image so you need to create the signature image with transparent background.

I have set my style for the svg as well as all the objects included to background-color: transparent; however it does not work. the image used in the annotation is a memory stream of the SVG so how do I set the image as transparent?

@gmitchell.ipipeline

We have created a ticket with ID PDFNET-49957 in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Meanwhile, you can convert this SVG file to a PNG image and share your feedback. joe.png (24.0 KB)

Would converting this ticket to paid support expedite the resolution? And would you have a timeframe?

@gmitchell.ipipeline

For now the ticket is logged under Free Support Model where issues are scheduled on first come first serve basis so escalating it to Paid Support will expedite the investigations.