We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

pdfimage transparency lost when inserted in pdf

Thread ID:





127624 Nov 29,2016 09:32 AM UTC Dec 2,2016 09:53 AM UTC WPF 3
Tags: PDF
Asked On November 29, 2016 09:32 AM UTC


I am using this basic code to insert an image that is generated on-the-fly, with some transparency added with a common wpf transparency function

Bitmap myBitmap = somegenerationfunctionhere();
myBitmap.MakeTransparent(System.Drawing.Color.White); // yes, my image does have some white !
PdfBitmap myPdfBitmap = new PdfBitmap(myBitmap);
page.Graphics.DrawImage(myPdfBitmap, ...);

.. and instead of having some transparency all the white becomes black. I am not doing any other manipulation mon myBitmap between the transpoarency and passing it to pdfimage
What is wrong in the code above ? or bug ?


Gayathri Ramalingam [Syncfusion]
Replied On November 30, 2016 02:31 PM UTC

Hi Fabrice, 
Thank you for using Syncfusion products.  
On analyzing your code snippet, we came to know that you have directly passed Bitmap image to PdfBitmap. You have to save the bitmap into memory stream before passing it to PdfBitmap. 
Please find the below code snippet, 
Bitmap bitmap = somegenerationfunctionhere(); 
MemoryStream imageStream = new MemoryStream(); 
PdfBitmap image = new PdfBitmap(imageStream);    
Please find the sample from the below link, 

Please let us know if you need further assistance.  

With Regards, 
Gayathri R 

Replied On December 1, 2016 08:43 AM UTC

Hi Gayathri,

(My code was not passing "directly", but initially using an Image as some SF examples ; this was a simplified version here, but it was not working either anyway)

But your method with a Stream, permitting to force a png format supporting transparency, works perfectly. Job done!

Thanks a lot,

Gayathri Ramalingam [Syncfusion]
Replied On December 2, 2016 09:53 AM UTC

Hi Fabrice 
We are glad that the issue is resolved at your end and please let us know if you need further assistance. 
With Regards, 
Gayathri R 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon