My GridView PDF print does not appear good when I printed it. How do I add margin and padding I order to create some horizontal and vertical space in the cells and make it look good?
GridView: HTML
<asp:GridView ID="GridView1" runat="server" GridLines="None" DataKeyNames="Id" AllowPaging="true" PageSize="10" HeaderStyle-ForeColor="#05214d" HeaderStyle-Font-Size="10pt" Font-Size="10pt"
AutoGenerateColumns="false" OnRowDataBound="OnRowDataBound" HeaderStyle-HorizontalAlign="left" RowStyle-HorizontalAlign="Left" OnPageIndexChanging="OnPageIndexChanging" HeaderStyle-BackColor="#f5f5f5" RowStyle-BackColor="#fdfdfd" AlternatingRowStyle-BackColor="White" AlternatingRowStyle-ForeColor="#000" class="table" Width="100%">
<EmptyDataTemplate>
<div style="text-align: center; font-weight: 500; margin-top: 2%;">
<i class="fal fa-file-times" style="margin: 0 auto; font-size: 30pt; color: #145c7c;"></i>
<p id="P1" runat="server" style="font-size: 11pt; font-weight: 400;">No Record</p>
</div>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="check" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="ID" HeaderStyle-Font-Bold="false" />
<asp:BoundField DataField="RegName" HeaderText="Name" HeaderStyle-Font-Bold="false" ItemStyle-Font-Size="10pt" />
<asp:BoundField DataField="phoneNumber" HeaderText="Phone Number" HeaderStyle-Font-Bold="false" ItemStyle-Font-Size="10pt" />
<asp:BoundField DataField="email" HeaderText="Email" HeaderStyle-Font-Bold="false" ItemStyle-Font-Size="10pt" />
<asp:BoundField DataField="RegDate" HeaderText="Date Registered" HeaderStyle-Font-Bold="false" ItemStyle-Font-Size="10pt" />
</Columns>
</asp:GridView>
Printing: C#
protected void ExportToPDF(object sender, EventArgs e)
{
string fileName = Topic.Text + ".pdf";
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
GridView1.AllowPaging = false;
this.GetRegistrationDetails();
GridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
cssResolver.AddCssFile(Server.MapPath("~/css/style2.css"), true);
pdfDoc.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename= " + fileName + ";");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
}
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}