0

I have created a code for preparing PDF from an HTML file. My problem is that generated PDF is not showing my HTML table's border. I am not using any CSS file all the stiles are written inline. Below is my HTML sample.

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0" width="100%" style=" font-family:'Times New Roman', Times, serif; font-size:12px; margin:20px 0px; border:10px solid #000; color:#000;">
<tr>
        <td  width="40%"  align="center"><img src="[LOGOIMAGE]" alt="logo" /></td>
        <td  width="30%" align="center" style="border-left:1px solid #000;">June, 26 2013<br />page 1 of 3</td>
        <td  width="30%" align="center" style="border-left:1px solid #000;">123456<br />Name</td>
    </tr>
</table>
</body>
</html>

I am also tried increasing the border width upto 10px because while Googling I found that some other developers also faced the same problem and tried this to resolve it, but this didn't worked for me.

I am using below code for generating PDF.

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Details.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
//  Document d = new Document(new Rectangle(100f, 300f));
var doc = new Document(PageSize.A4, 50, 50, 25, 25);

// Create a new PdfWriter object, specifying the output stream
var output = new MemoryStream();
//    var writer = PdfWriter.GetInstance(doc, output);

string path = Server.MapPath("pdfs");
PdfWriter.GetInstance(doc, new FileStream(path + "/doc3.pdf", FileMode.Create));
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
string contents = File.ReadAllText(Server.MapPath("myfile.html"));
contents = contents.Replace("[LOGOIMAGE]", Server.MapPath("App_Data/images/logo.jpg"));

var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(contents), null);

// Enumerate the elements, adding each one to the Document...
foreach (var htmlElement in parsedHtmlElements)
    doc.Add(htmlElement as IElement);
doc.Close();
Response.Write(doc);
Response.End();
Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Nikhil Gaur
  • 1,280
  • 3
  • 19
  • 40

1 Answers1

0

If you change border="1" they will show up.

Craig
  • 1,205
  • 2
  • 21
  • 54