Drawing Image from Stream to PdfGrid cell
Hi,
I'd like to insert an image from a byte stream to a PdfGrid cell.
Here is my code:
Image img;
using( MemoryStream ms = new MemoryStream() )
{
ms.Write(imgByteArray, 0, imgByteArray.Length);
ms.Seek(0, 0);
img = Image.FromStream(ms, true);
}
PdfBitmap pBmp = new PdfBitmap(img);
pGrid.Rows[0].Cells[0].Value = pBmp;
The cell where the image should reside is empty. What is wrong?
I'd like to insert an image from a byte stream to a PdfGrid cell.
Here is my code:
Image img;
using( MemoryStream ms = new MemoryStream() )
{
ms.Write(imgByteArray, 0, imgByteArray.Length);
ms.Seek(0, 0);
img = Image.FromStream(ms, true);
}
PdfBitmap pBmp = new PdfBitmap(img);
pGrid.Rows[0].Cells[0].Value = pBmp;
The cell where the image should reside is empty. What is wrong?
SIGN IN To post a reply.
10 Replies
SS
Sri Subhashini M
Syncfusion Team
July 28, 2009 10:24 AM UTC
Hi Andreas,
Thank you for your interest in Essential PDF.
Drawing image in PdfGrid
I am able to see the issue that you have mentioned here. But this can solve by using BackgroundImage property of the PdfGrid.
Could you please try the below code snippets in your sample and let me know if this helps,
Regards,
Suba
Thank you for your interest in Essential PDF.
Drawing image in PdfGrid
I am able to see the issue that you have mentioned here. But this can solve by using BackgroundImage property of the PdfGrid.
Could you please try the below code snippets in your sample and let me know if this helps,
PdfBitmap pBmp = new PdfBitmap(@"..\..\Data\pdf_button.png");
pGrid.Rows[0].Cells[0].Style.BackgroundImage = pBmp;
pGrid.Rows[0].Cells[0].Value = "";
Regards,
Suba
AH
Andreas Hirtzel
July 28, 2009 11:11 AM UTC
Hi Suba,
thank you for reply. Your suggestion works great. With stream, too. Here is the code:
Image img;
MemoryStream ms = new MemoryStream();
ms.Write(imgByteArray, 0, imgByteArray.Length);
img = Image.FromStream(ms, true);
PdfImage pBmp = new PdfBitmap(img);
pGrid.Rows[0].Cells[0].Style.BackgroundImage = pBmp;
pGrid.Rows[0].Cells[0].Value = "";
Thanks!
thank you for reply. Your suggestion works great. With stream, too. Here is the code:
Image img;
MemoryStream ms = new MemoryStream();
ms.Write(imgByteArray, 0, imgByteArray.Length);
img = Image.FromStream(ms, true);
PdfImage pBmp = new PdfBitmap(img);
pGrid.Rows[0].Cells[0].Style.BackgroundImage = pBmp;
pGrid.Rows[0].Cells[0].Value = "";
Thanks!
SS
Sri Subhashini M
Syncfusion Team
July 28, 2009 11:28 AM UTC
Hi Andreas,
Glad to hear that it works great. Please let me know if you have any other queries.
Regards,
Suba
AH
Andreas Hirtzel
January 10, 2010 06:45 PM UTC
Hi,
I hadf to span the image over some cells, now. The problem is, that the image has the same size as the merged cells has. Is there an other way to draw an image in a grid cell?
I hadf to span the image over some cells, now. The problem is, that the image has the same size as the merged cells has. Is there an other way to draw an image in a grid cell?
MR
Meiyappan R
Syncfusion Team
January 19, 2010 05:32 AM UTC
Hi Andreas,
Could you please look into the sample provided in the below link.
http://help.syncfusion.com/samples/pdf/GridColumnspan.zip
Kindly let us know if it works.
Regards
Meiyappan
Could you please look into the sample provided in the below link.
http://help.syncfusion.com/samples/pdf/GridColumnspan.zip
Kindly let us know if it works.
Regards
Meiyappan
AH
Andreas Hirtzel
January 21, 2010 09:06 AM UTC
Hi Meiyappan,
this is, what I have done before. Run your sample and look at the image in cell and compare it with the original image file. You'll see, it is stretched. I think, there must be an other way to draw an image in PdfGrid cell.
Regards,
Andreas
this is, what I have done before. Run your sample and look at the image in cell and compare it with the original image file. You'll see, it is stretched. I think, there must be an other way to draw an image in PdfGrid cell.
Regards,
Andreas
MR
Meiyappan R
Syncfusion Team
February 17, 2010 03:41 AM UTC
Hi Andreas,
Sorry for the delay caused in getting back to you.
We are able to see that the image is stretched.For drawing the image in its exact size we have to manually set the columns width and height same as the width and height of the image.
Kindly let us know if you have any concerns.
Regards
Meiyappan
Sorry for the delay caused in getting back to you.
We are able to see that the image is stretched.For drawing the image in its exact size we have to manually set the columns width and height same as the width and height of the image.
Kindly let us know if you have any concerns.
Regards
Meiyappan
MR
Meiyappan R
Syncfusion Team
February 17, 2010 04:31 AM UTC
Hi Andreas,
Could you please download the sample from the below link in which the dimensions of the rows and columns are set manually so that the image size is preserved in the Grid cell.
http://help.syncfusion.com/samples/pdf/ColumnSpan_new.zip
Kindly let us know if you have any questions.
Regards
Meiyappan
Could you please download the sample from the below link in which the dimensions of the rows and columns are set manually so that the image size is preserved in the Grid cell.
http://help.syncfusion.com/samples/pdf/ColumnSpan_new.zip
Kindly let us know if you have any questions.
Regards
Meiyappan
BD
Bill Davidheiser
September 20, 2013 10:23 PM UTC
I'm working with a PDFGrid and I need to embed an Icon in a cell that plays a sound annotation.
I was given an example where the SoundAnnotation needs to be placed by giving it an x,y coordinates which is not an option as I won't be able to always accurately place it in the right cell if the pdf paginates.
any suggestions?
var dt = new DataTable();
dt.Columns.Add("column1");
dt.Columns.Add("column2");
dt.Columns.Add(" ");
foreach (var question in questions)
{
var dr = dt.NewRow();
dr[0] = question.remark;
dr[1] = "";
dr[2] = question.answer; //I would like place here an icon that play the sound annotation
dt.Rows.Add(dr);
}
var questionFrame = new PdfGrid();
questionFrame.DataSource = dt;
questionFrame.Columns[1].Width = 25;
questionFrame.Style.Font = _fontSpecs;
questionFrame.Style.TextBrush = _grayBrush;
questionFrame.Style.CellPadding.Top = questionFrame.Style.CellPadding.Bottom = 5f;
questionFrame.Style.CellPadding.Left = 5;
questionFrame.Style.CellPadding.Right = 5;
foreach (PdfGridRow header in questionFrame.Headers)
{
foreach (PdfGridCell cell in header.Cells)
{
cell.Style.Borders.All = PdfPens.White;
}
header.Style.Font = _boldFontStyle;
header.Style.TextBrush = _blackBrush;
header.Cells[1].ColumnSpan = 2;
}
KC
Karthikeyan Chandrasekar
Syncfusion Team
October 1, 2013 03:48 AM UTC
Hi Bill,
Thank you for using Syncfusion Products.
We could not able to directly draw the PdfSound Annotation in to the PdfGrid cell, we have to manually calculate the coordinate values. However this can be achieved only in PdfLightTable by using the Event Handlers. Please find below the online sample link for how to use the event handlers.
http://asp.syncfusion.com/Windows/demos/reporting/pdf/tables/Table%20Features/Sample.aspx
Please let us know if you need any further assistance.
Thanks,
Karthikeyan.C
SIGN IN To post a reply.
- 10 Replies
- 5 Participants
-
AH Andreas Hirtzel
- Jul 27, 2009 08:10 PM UTC
- Oct 1, 2013 03:48 AM UTC