- Home
- Forum
- ASP.NET Web Forms (Classic)
- How to draw a transparent png
How to draw a transparent png
Hello,
var g = (page as PdfPageBase).Graphics;
PdfImage pdfImg = new PdfBitmap(bmp);
g.DrawImage(pdfImg, location.X, location.Y);
_______________________________________________________________________
Temp_65569607.zip
I am trying to draw a png that has a transparent background on a page using ASP.NET pdf. The transparent pixels come out black. Here is what I'm trying:
_______________________________________________________________________
bmp = new System.Drawing.Bitmap("c:\\Temp\\Bitmap3.png");var g = (page as PdfPageBase).Graphics;
PdfImage pdfImg = new PdfBitmap(bmp);
g.DrawImage(pdfImg, location.X, location.Y);
_______________________________________________________________________
Do I need to create a PdfImageMask or a PdfColorMask to make this work?
The attachment contains the png I am working with and the pdf after I've inserted the png on page 8.
What am I missing?
Thanks,
Jeff
Temp_65569607.zip
SIGN IN To post a reply.
3 Replies
GL
George Livingston
Syncfusion Team
April 2, 2013 04:35 AM UTC
Hi Jeff,
Thank you for using Syncfusion product.
We are not able to reproduce the issue using the version
11.1.0.21, herewith we have attached the sample with which we tried to
reproduce the issue. Can you please provide us a sample or modify this sample
to reproduce the issue. Also please let us know the Essential studio version
you are using.
Please let us know if you have any questions.
Regards,
George
JG
Jeff Gilbert
April 18, 2013 02:17 PM UTC
I figured out the problem. This works to create a transparent png:
This is the way I was doing it before. It creates an image with a white background:private PdfImage DrawImage(PdfPageBase page, Bitmap bmp, RectangleF location){var ms = new MemoryStream();bmp.Save(ms, ImageFormat.Png);var pdfImg = new PdfBitmap(ms);var g = (page as PdfPageBase).Graphics;g.DrawImage(pdfImg, location.X, location.Y);
private PdfImage DrawImage(PdfPageBase page, Bitmap bmp, RectangleF location){var g = page.Graphics;PdfImage pdfImg = new PdfBitmap(bmp);g.DrawImage(pdfImg, location.X, location.Y);
Cheers,
Jeff
GL
George Livingston
Syncfusion Team
April 19, 2013 04:02 AM UTC
Hi Jeff,
Thank you for your update.
We are glad to hear that the issue has been resolved.
Please let us know if you have any concerns.
Regard,
George
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JG Jeff Gilbert
- Mar 30, 2013 12:02 AM UTC
- Apr 19, 2013 04:02 AM UTC