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.

Drawing Image from Stream to PdfGrid cell

Thread ID:

Created:

Updated:

Platform:

Replies:

88503 Jul 27,2009 04:10 PM Sep 30,2013 11:48 PM Windows Forms 10
loading
Tags: PDF
Andreas Hirtzel
Asked On July 27, 2009 04:10 PM

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?

Sri Subhashini M [Syncfusion]
Replied On July 28, 2009 06:24 AM

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,


PdfBitmap pBmp = new PdfBitmap(@"..\..\Data\pdf_button.png");
pGrid.Rows[0].Cells[0].Style.BackgroundImage = pBmp;
pGrid.Rows[0].Cells[0].Value = "";


Regards,
Suba

Andreas Hirtzel
Replied On July 28, 2009 07:11 AM

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!

Sri Subhashini M [Syncfusion]
Replied On July 28, 2009 07:28 AM


Hi Andreas,

Glad to hear that it works great. Please let me know if you have any other queries.

Regards,
Suba

Andreas Hirtzel
Replied On January 10, 2010 01:45 PM

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?

Meiyappan R [Syncfusion]
Replied On January 19, 2010 12:32 AM

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

Andreas Hirtzel
Replied On January 21, 2010 04:06 AM

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

Meiyappan R [Syncfusion]
Replied On February 16, 2010 10:41 PM

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

Meiyappan R [Syncfusion]
Replied On February 16, 2010 11:31 PM

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

Bill Davidheiser
Replied On September 20, 2013 06:23 PM

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;
            }

KarthikeyanC [Syncfusion]
Replied On September 30, 2013 11:48 PM

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


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.

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.

;