我有一个包含员工表中员工数据的网页。我调用GetEmployeeDetails()函数来获取详细信息。我有GetEmployeeDetails()的服务。我想将此数据探索为PDF。如何调用GetEmployeeDetails()函数? 我在webConfig中定义了fileUploadLoc。 我有以下代码。我不知道如何调用该服务功能。
Document pdfDoc = new Document(PageSize.A4, 25, 10, 25, 10);
DirectoryInfo destination = new DirectoryInfo(Server.MapPath("~/" + fileUploadLoc));
Directory.CreateDirectory(Server.MapPath("~/" + fileUploadLoc ));
destination = new DirectoryInfo(Server.MapPath("~/" + fileUploadLoc ));
destination.Create();
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfWriter.Open();
StringWriter sw = new StringWriter();
StringReader sr = new StringReader(sw.ToString());
ArrayList htmlList = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, null);
foreach (IElement el in htmlList)
{
pdfWriter.Add(el);
}
pdfDoc.Close();
我找到了解决方案:
DataSet obj = new DataSet();
obj = objServiceClient.GetEmployeeList();
StringBuilder sb = new StringBuilder();
if (obj.Tables[0].Rows.Count > 0)
{
sb.Append("<html>");
sb.Append("<head>");
sb.Append("</head>");
sb.Append("<body >");
sb.Append("</body >");
sb.Append("</html >");
}
StringReader sr = new StringReader(sb.ToString());
ArrayList objects = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, styles);
for (int k = 0; k < objects.Count; k++)
{
pdfDoc.Add((IElement)objects[k]);
}
标签<hr>
有问题。它没有显示水平线。而<table>
“边框”未显示。请帮帮我。