Click here to Skip to main content
15,888,061 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to set spacing between two html tables and border in the top portion alone while rendering the same to PDF in asp.net . I am able to do so in html page by setting the td containing table with padding but while rendering to pdf file the space is not coming.

StringBuilder strBuilder = new StringBuilder();


strBuilder.Append("<table cellSpacing=0 cellPadding=0 width='100%' align='center' border='0'>");
strBuilder.Append("<tr>");
 strBuilder.Append("<td>");
 strBuilder.Append("<table style='border-top: 1px solid #000000;' cellSpacing=0 cellPadding=0 width='100%'>");
strBuilder.Append("<tr>");
strBuilder.Append("<td style='HEIGHT: 33px;padding-left:65px; width: 136px;' align='left' colspan='2'>");

strBuilder.Append("Outward");
strBuilder.Append("</td>");
strBuilder.Append("</tr>");

strBuilder.Append("</table>");
strBuilder.Append("</td>");


//strBuilder.Append("<td style='padding-left:65px;'>");
strBuilder.Append("<td style='align:right'>");
strBuilder.Append("<table border='1' cellSpacing=0 cellPadding=0 width='100%'>");
strBuilder.Append("<tr>");
strBuilder.Append("<td style='HEIGHT: 33px;padding-left:65px; width: 136px;' align='left' colspan='2'>");

strBuilder.Append("Inward");
strBuilder.Append("</td>");
strBuilder.Append("</tr>");

strBuilder.Append("</table>");
strBuilder.Append("</td>");
strBuilder.Append("</table>");


What I have tried:

I am rendering the html table to PDF via itextsharp. Passing the style as Inline. Even after setting padding for the td containing table and border top alone as style it is not working in PDF. It comes fine in html page.
Posted
Updated 3-Jan-17 17:41pm
v2

1 solution

You try to apply this format
C#


Font DateHeading = new Font(FontFactory.GetFont("helvetica", 12, Font.NORMAL));

PdfPTable ExamDetails = new PdfPTable(1);


PdfPCell ExamDateCell = new PdfPCell(new Phrase("Name", DateHeading));
            ExamDateCell.BorderWidth = 0;
            ExamDateCell.PaddingTop = 10f;
            ExamDateCell.HorizontalAlignment = Element.ALIGN_CENTER;
            ExamDetails.AddCell(ExamDateCell);
           ExamDetails.SpacingBefore = 200;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900