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

Display PdfPageNumberField in a PdfGrid Cell

I want to insert the page number (PdfPageNumberField) into a grid cell (in the grid header).  Can't figure out how to do that.

3 Replies

KK Karthik Krishnaraj Syncfusion Team November 17, 2014 12:24 PM UTC

 Hi Mark,


Thank you for your interest in Syncfusion products.

 I have attached a simple sample for your reference regarding how to add page number into grid cell,
 We hope it will be helpful for you, please let me know if you need any further assistance.
 
 Thanks,

 Karthik


Attachment: PdfNumberFieldGridCell_4feb38c1.zip


MS Mark Schramm November 17, 2014 11:02 PM UTC

I'm sorry but the sample project you provided just sticks the page number in the top left hand corner of the page.  If that happened to be where the cell was it was just lucky.

I would think the line: compositeField.Draw(myPage.Graphics)
just dumps the thing on page. while: pageheaderRow.Cells[9].Value = compositeField;
isn't going to do anything as no draw is executed.  Unless I'm misunderstanding some sort of redirection.  Anyway in tests the page number just blots in the top left of the page and it's not useful there.

Mark


KK Karthik Krishnaraj Syncfusion Team November 18, 2014 05:17 PM UTC

Hi Mark,

 

Sorry for the inconvenience caused, for now we don’t have support for adding page number in Pdf Grid at respective cell position, whereas this is possible using PdfLightTable, I have attached a simple sample for your reference can you please check through it and let me know if you need any further assistance, I have included a code snippet about the working of cell layout event below please look through it.



//This event will be called every time when cell is created

private void lightTable_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)

{

//Use to draw at specified cell index

if (args.CellIndex == 1)

 {

//Getting the boundaries of the Cell

RectangleF rect = new System.Drawing.RectangleF(args.Bounds.X, args.Bounds.Y, args.Bounds.Width, args.Bounds.Height);

//Create page number field

PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);

PdfPageCountField count = new PdfPageCountField(font, brush);

PdfCompositeField compositeField = new PdfCompositeField(font, brush,Page NO {0}", pageNumber);

//Drawing Page number in  respective boundaries of cell

compositeField.Draw(args.Graphics, new System.Drawing.PointF(rect.X,   rect.Y));

    }

   }


Thanks,

Karthik


Attachment: PdfNumberField_516eab50.zip

Loader.
Up arrow icon