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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem show image in PdfLightTable

Thread ID:





149448 Nov 26,2019 08:10 PM UTC Jan 3,2020 11:32 AM UTC Xamarin.Forms 3
Tags: PDF
Marcelo Garcia Skocynski
Asked On November 26, 2019 08:10 PM UTC

Good afternoon

I need the image in the "Image" column on my grid

//string imageAsString = "/9j/4Rc7RXhpZgAATU0AKgAAAAgA.....";
            byte[] data = new byte[imageAsString.Length];
            MemoryStream stream = new MemoryStream(data);

            PdfColumn colImagem = new PdfColumn("IMAGEM");
            colImagem.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
            colImagem.Width = 100;

            PdfColumn colCodigo = new PdfColumn("CÓDIGO");
            colCodigo.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
            colCodigo.Width = 40;
string Codigo = "ABC";
pdfLightTable.Rows.Add(new object[] { stream, Codigo);
It occurs that when sending to the PDF, it does not show the image. 

This showing only the string "System.IO.MemoryStream...

Can someone help me....

Thank you

Sowmiya Loganathan [Syncfusion]
Replied On November 27, 2019 01:36 PM UTC

Hi Marcelo, 

Thank you for contacting Syncfusion support.  

We can able to add the image in PDF table cell by using BeginCellLayout event handler. Please refer the below code snippet for more details, 

//Create a new PDF document 
PdfDocument document = new PdfDocument(); 
//Add a page 
PdfPage page = document.Pages.Add(); 
//Create a PdfLightTable 
PdfLightTable pdfLightTable = new PdfLightTable(); 
//Create a data table 
DataTable dataTable = new DataTable(); 
//Add columns to data table 
//Add rows to data table  
dataTable.Rows.Add("Adventure Cycle", ""); 
//Assign data source 
pdfLightTable.DataSource = dataTable; 
pdfLightTable.BeginCellLayout += pdfLightTable_BeginCellLayout; 
pdfLightTable.BeginRowLayout += PdfLightTable_BeginRowLayout; 
pdfLightTable.Style.ShowHeader = true; 
//Draw light table to the page of PDF document 
pdfLightTable.Draw(page, new RectangleF(0, 50, page.GetClientSize().Width, page.GetClientSize().Height));  

Event handlers:  

private void PdfLightTable_BeginRowLayout(object sender, BeginRowLayoutEventArgs args) 
    if (args.RowIndex == 0) 
        args.MinimalHeight = 100; 
private void pdfLightTable_BeginCellLayout(object sender, BeginCellLayoutEventArgs args) 
    //Draw image in the same cell 
    if (args.RowIndex==0 && args.CellIndex == 1) 
        //Load the image as stream 
        Stream imageStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("Sample.Assets.Image.jpg"); 
        PdfBitmap image = new PdfBitmap(imageStream); 
        //Draw image  
        args.Graphics.DrawImage(image, args.Bounds.X, args.Bounds.Y , args.Bounds.Width, args.Bounds.Height); 

Please try the above solution in your end and let us know the result. 

Sowmiya Loganathan 

Sarasilmiya Shahul Hameed [Syncfusion]
Replied On November 28, 2019 05:03 AM UTC

From: marcelo 
Sent: Wednesday, November 27, 2019 12:05 PM
Subject: RES: Syncfusion support community forum 149448, Problem show image in PdfLightTable, has been updated. 
Good afternoon. 

The example sent is working perfectly, but if there is more than one image does not appear the others. only the first image. In case I have a list of products with your images and as an example sent, it would be only for one image. 

I need some help. 

Thank you 

Sowmiya Loganathan [Syncfusion]
Replied On January 3, 2020 11:32 AM UTC

Hi Marcelo, 

We have created the sample to add two images in one PDF table cell. Please find the sample for the same from below, 

Please try the above solution in your end and let us know the result.  

Sowmiya Loganathan 


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

Live Chat Icon For mobile
Live Chat Icon