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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

pdfimage transparency lost when inserted in pdf

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,

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 ?

Thanks,
F

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(); 
 
bitmap.MakeTransparent(System.Drawing.Color.White); 
 
MemoryStream imageStream = new MemoryStream(); 
 
bitmap.Save(imageStream,System.Drawing.Imaging.ImageFormat.Png); 
 
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 


fff
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,
Fabrice

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 


CONFIRMATION

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.

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

;