PdfLightTable Cell text alignment

I'm trying to put a header on my PDF pages that has the title on the left and the current date on the right. I can't seem to figure it out. I tried using the PdfTextElement but I can't seem to draw that to the PdfPageTemplateElement and give it a PdfStringFormat with a RightAlignment.

So I next tried to do a PdfLightTable by building up a DataTable for those two items. But I can't figure out how to do an alignment within a table cell.

Also, with your older versions I think I remember being able to build up a table programmatically which gave me much more control over each cell because I could give each one a CellStyle. Is there a way to do tables this way in version 6.1?


1 Reply

YG Yavanaarasi G Syncfusion Team February 11, 2008 06:07 AM UTC

Hi Jeff,

Sorry for the delay in responding.

1.How to do an alignment within a table cell?

You can use the following code snippet for alignment within a table cell:


[C#]
PdfStringFormat sf2 = new PdfStringFormat(PdfTextAlignment.Right);
PdfStringFormat sf1 = new PdfStringFormat(PdfTextAlignment.Left);


2.I could give each one a CellStyle. Is there a way to do tables this way in version 6.1?

Yes.It is possible in our new PDF. You can Use below code snippet for setting cellstyle:

[c#]
PdfCellStyle altStyle = new PdfCellStyle();
altStyle.Font =font;
altStyle.BackgroundBrush = brush;
altStyle.BorderPen = borderPen;
altStyle.StringFormat = sf2;


Please refer the sample in the below link which illustrates the above:

http://websamples.syncfusion.com//samples/PDF.Windows/F-71627/main.htm

Here is the documentation link for table features and formatting the table in new PDF:

http://www2.syncfusion.com/ug_latest/pdf/Tables.html

Please try running the above sample and let me know if this helps.

Regards,
G.Yavana



Loader.
Up arrow icon