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

Free Support Forum - aspose.com

Add SVG in PDF as ImageStamp in C# using Aspose.PDF for .NET

Hi support,

I tried adding an SVG image to an ImageStamp. This results in a “Parameter is not valid” error. How do I fix this?

using (var imageStream = new MemoryStream(UC.PDF.Business.Properties.Resources.iconen))
{
var image = new Aspose.Pdf.Image
{
FileType = ImageFileType.Svg,
ImageStream = imageStream,
FixWidth = 178.58,
FixHeight = 28.35
};
imageStamp = new ImageStamp(image.ImageStream);
foreach (var page in document.Pages)
{
page.AddStamp(imageStamp);
}
}

Best regards,
Marcel

@Snaak1968

Thank you for contacting support.

Would you please share your sample SVG file as ZIP so that we may try to reproduce and investigate it in our environment.

svg.zip (4.3 KB)

@Snaak1968

We have tested the scenario in our environment using following code snippet which is correct way to add Image Stamp inside PDF and faced an OOM (Out Of Memory) exception.

Add Image Stamp Using Aspose.PDF

Document pdfDocument = new Document(dataDir + "Flatten.pdf");
ImageStamp imageStamp = new ImageStamp(dataDir + "iconen.svg");
imageStamp.Background = true;
imageStamp.Opacity = 0.5;
imageStamp.HorizontalAlignment = HorizontalAlignment.Center;
imageStamp.VerticalAlignment = VerticalAlignment.Center;
// Add stamp to particular page
for (int i = 1; i <= pdfDocument.Pages.Count; i++)
    pdfDocument.Pages[i].AddStamp(imageStamp);
pdfDocument.Save(dataDir + "ImageStamp_out1true.pdf");

We have logged an issue as PDFNET-47463 in our issue tracking system for further investigation. We will check this issue in details and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi, @asad.ali! Any progress on this? Still get “out of memory” for svg. Aspose.Pdf 20.8.0

@mgkcortyw

Regretfully, the ticket is still unresolved. It is related to performance of the API and performance related issues are complex in nature. The issue needs more time to get fully analyzed and resolved. We will let you know as soon as we have additional updates regarding its fix. Please give us some time.

We are sorry for the inconvenience.