Hello,
I am using Infragistics version 15.2.20152.1027.
When I generate PDF documents using the Infragistics.Documents framework, I frequently include JPEG or PNG images with transparent backgrounds. However, sometimes those images are rendered in my PDF with a black background even though the background is supposed to be transparent.
This doesn't happen every time. For example, I could generate one document and the image might have a black background. But then 5 minutes later I could generate the same document and the image would have a transparent background.
Please see my code sample below:
Dim report As Report Dim section As ISection Dim table As ITable Dim row As ITableRow Dim cell As ITableCell Dim canvas As ICanvas Dim img As Image ' set printing options report = New Report() report.Preferences.Printing.PaperSize = Preferences.Printing.PaperSize.Legal report.Preferences.Printing.PaperOrientation = PaperOrientation.Portrait ' set section options section = report.AddSection() section.PageOrientation = Infragistics.Documents.Reports.Report.PageOrientation.Portrait section.PageSize = PageSizes.Legal section.PageMargins.Left = 40 section.PageMargins.Right = 40 section.PageMargins.Top = 30 section.PageMargins.Bottom = 30 table = section.AddTable() table.Width = New RelativeWidth(100) row = table.AddRow() cell = row.AddCell() cell.Width = New RelativeWidth(100) cell.Alignment.Horizontal = Alignment.Center cell.Alignment.Vertical = Alignment.Middle img = New Image("C:/project/images/logo.jpg") canvas = cell.AddCanvas() canvas.Width = New FixedWidth(300) canvas.Height = New FixedHeight(65) canvas.DrawImage(img, 0, 0, 300, 65) ' save the PDF document report.Publish("C:/project/reports/sample_report.pdf", FileFormat.PDF)
Thank you for contacting Infragistics!
I will investigate this matter to see what may be causing this behavior. Can you please attach the image you are using that reproduces this behavior you so I may use it in creating my own sample to attempt to reproduce this behavior?
I have attached one image that is known to have this problem. When you generate the PDF document, the image should appear with a black background.
Unfortunately I still have not gotten a response from the Infragistics team. They opened a case to investigate the issue and I am still waiting for an answer.
I have the exact same issue in C# after upgrading from Infragistics 9.2 to 16.2.20162.2111.
I am interested to know if you found the issue and if you have a workaround despite removing the transparency from the picture?
Here is the function I am using.
private void DrawImage(Graphics grfx, RectangleF rectangle) {
Bitmap bitmap = image as Bitmap;
if (bitmap != null) bitmap.MakeTransparent();
grfx.DrawImage(image, rectangle);
}
I am creating the Graphics object in other class as below:
Report report = new Report();
ISection section = report.AddSection();
section.PageSize = PageSizes.A4;
section.PageSize = new PageSize(paperRectangle.Width * 2.54F, paperRectangle.Height * 2.54F);
ICanvas canvas = section.AddCanvas();
Graphics grfx = canvas.CreateGraphics();
Best regards.
Florian Jacquelet
Senior Software Developer
Thank you for the update. I have logged this for further investigation with the ID# 237829. I have created a private case CAS-184299-V4P8D3 where I will provide you with more details.