ITextSharp: Align cell while exporting GridView to PDF in ASP.Net

Last Reply 6 months ago By Codemat

Posted 6 months ago

Hello, I apologize if the topic has already been dealt with but I can not find a solution in this regard.
I am exporting a gridview with iTextSharp, as in this example:

https://www.aspsnippets.com/Articles/Export-Paging-enabled-Gridview-to-PDF-with-Formatting-using-iTextSharp-in-ASPNet.aspx

The problem is that the output obtained is completely misaligned and not corresponding to what I see on the screen.

I protected everything, with css (text-align: center;), with ItemStyle-HorizontalAlign = "Left" in the templatefiled headers, but nothing, the text is not aligned.

tips? or alternatives?

best regards

Posted 6 months ago Modified on 6 months ago

Hello pandeyism thank you for your time

For the moment I solved differently, that is changing the approach with the code.

Basically I build directly the table I need, through iTextSharp, cycling the datatable, as indicated by @Mudassar in this topic:

iTextSharp: How to convert HTML Table string to PDF using C# .Net

Thanks again