Free Support Forum -

Problem stamping GIF image with transparent background on a PDF


I have the following code:

	       //Open document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputPdfFile);
           <span style="color:green;">//Create image stamp</span>
           Aspose.Pdf.<span style="color:#2b91af;">ImageStamp</span> imageStamp = <span style="color:blue;">new</span> Aspose.Pdf.<span style="color:#2b91af;">ImageStamp</span>(imageFile);
           imageStamp.Background = background;
           imageStamp.XIndent = lowerLeftX;
           imageStamp.YIndent = lowerLeftY;
           imageStamp.Height = upperRightY - lowerLeftY;
           imageStamp.Width = upperRightX - lowerLeftX;
           <span style="color:green;">//Add stamp to particular page</span>

           <span style="color:green;">//Save output document</span>
           pdfDocument.Save(outputPdfFile);</pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><span style="font-family: 'Times New Roman'; font-size: medium; white-space: normal;">My problem is that when the GIF has transparent background, this code puts a BLACK background on the image.</span></pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><span style="font-family: 'Times New Roman'; font-size: medium; white-space: normal;">Stamping the same files with iTextSharp does the job perfectly.</span></pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><br></pre></div>

Hi Nir,

Thanks for your inquiry. I have tested the stamping scenario with a sample transparent GIF image using Aspose.Pdf for .NET 10.1.0 and managed to observe the reported issue. For further investigation and rectification, I have logged an issue in our issue tracking system as PDFNEWNET-38267 and also linked your request to it. We will keep you update via this thread regarding the issue status.

Moreover, we will appreciate it if you please share your sample image here as well. It will help us to address your issue exactly.

Please feel free to contact us for any further assistance.

Best Regards

What about this??

Hi Nir,

Thanks for your inquiry. I am afraid the issue is still not resolved as product team was busy in resolving other high priority issues. However, I have raised your issue priority and requested our team to complete the issue investigation and share an ETA at their earliest. We will notify you as soon as we get a feedback.

We are sorry for the inconvenience.

Best Regards,

Well, it’s been over two years now…
by the way, PNG images with transparent background works fine.

Hi Nir,

We are sorry for the inconvenience. Actually issue had a low priority, however we have already increased the issue priority and recorded your concern as well. We will let you know as soon as some update is available.

Thanks for your patience and cooperation.

Best Regards,

Please also note that adding a image with transparent background using the Aspose.Pdf.Document object, also does not work. Here, PNG and GIF both render with black background

Hi Nir,

We are sorry for the inconvenience. Please also share your sample PNG image with transparent background, it will help us to investigate and address you issue exactly.

Best Regards,

Here is the file.

Hi Nir,

Thanks for sharing the sample image. I have tested the scenario with Aspose.Pdf for .NET 16.11.0 and unable to notice black background issue. I will appreciate it if you please try the scenario with latest version and share the results. If the issue persist then please share your sample code here as well, so we will look into it and will guide you accordingly.

//Open document<o:p></o:p>

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(myDir + "Lenovo_Tablet_2_Pag1.pdf");

//Create image stamp

Aspose.Pdf.ImageStamp imageStamp = new Aspose.Pdf.ImageStamp(myDir + "TOC.png");

imageStamp.Background = false;

imageStamp.XIndent = 400;

imageStamp.YIndent = 400;

imageStamp.Height = 100;

imageStamp.Width = 100;

//Add stamp to particular page


//Save output document

pdfDocument.Save(myDir + "transparenttest.pdf");

Best Regards,

The issues you have found earlier (filed as PDFNET-38267) have been fixed in Aspose.PDF for .NET 18.10.