Rank: Newbie Groups: Member
Joined: 2/4/2013 Posts: 7
|
Hi, Up until now I have been converting html strings to PDF with great success. I now need to display a table with some basic styling and the PDF document doesn't render the table styling. Below is my code:
Code: HTML/ASPX
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="http://ggsappdev/TimbertopScheduler/Style_Print.css" />
</head>
<body>
<h1>Music Students</h1>
<table class="content">
<tr>
<th>Student Name</th>
<th>Unit</th>
<th>School</th>
<th>Elective</th>
<th>Instrument</th>
<th>Teacher Name</th>
<th>Comment</th>
</tr>
<tr class="row">
<td>A, Anthony</td>
<td>D</td>
<td>B</td>
<td>False</td>
<td>Piano</td>
<td>A, Clare</td>
<td></td>
</tr>
<tr class="row">
<td>C, Oliver</td>
<td>A</td>
<td>B</td>
<td>False</td>
<td>Piano</td>
<td>A, Clare</td>
<td></td>
</tr>
<tr class="row">
<td>A, David</td>
<td>A</td>
<td>B</td>
<td>False</td>
<td>Bass Guitar</td>
<td>A, Stewart</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>False</td>
<td>Piano</td>
<td>Airs, Clare</td>
<td></td>
</tr>
</table>
</div></div>
</body>
</html>
Code: CSS
table.content
{
width: 100%;
border-collapse: collapse;
padding: 0px;
margin: 0px;
font-family: Arial;
font-size: 11px;
line-height: 1.4;
}
.content th
{
border: solid 1px #000000;
text-align: left;
}
.content .row
{
border-top: solid 1px #000000;
}
Code: C#
Directory.CreateDirectory("\\\\[server]\\PDF_Temp\\" + this.Session.SessionID.ToString() + "");
string outputFileName = "\\\\[server]\\PDF_Temp\\" + this.Session.SessionID.ToString() + "\\" + iNAME + ".pdf";
if(iORIENTATION == "Landscape")
{
EO.Pdf.HtmlToPdf.Options.PageSize = new SizeF(11f, 8.5f);
HtmlToPdf.Options.OutputArea = new RectangleF(0.4f, 0.15f, 11.5f, 7.5f);
}
else
{
HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4;
HtmlToPdf.Options.OutputArea = new RectangleF(0.4f, 0.15f, 7.5f, 11.5f);
}
EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "<div style='text-align:right; font-family: Arial'>{page_number} / {total_pages}</div>";
HtmlToPdf.ConvertHtml(iDATA, outputFileName);
Response.Redirect("[server]" + this.Session.SessionID.ToString() + "/" + iNAME + ".pdf", false);
Should I be able to style tables with EO.PDF or have a stumbled across an extremely unfortunate limitation. King Regards, Eloise
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
Whenever you use external CSS files, you have to set HtmlToPdf.Options.BaseUrl correctly when you use ConvertHtml. Otherwise the HTML to PDF converter won't know where to find the CSS file.
Thanks!
|