Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用asp.net将网页导出为pdf_C# - Fatal编程技术网

C# 使用asp.net将网页导出为pdf

C# 使用asp.net将网页导出为pdf,c#,C#,我有一个包含employee表中的员工数据的网页。我调用了GetEmployeeDetails函数来获取详细信息。我有获取员工详细信息的服务。我想把这些数据转换成PDF格式。如何调用GetEmployeeDetails函数? 我在webConfig中定义了fileUploadLoc。 我有以下代码。我不知道如何调用该服务功能 Document pdfDoc = new Document(PageSize.A4, 25, 10, 25, 10); DirectoryInfo destination

我有一个包含employee表中的员工数据的网页。我调用了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]);
      }

我的标签有问题。它没有显示水平线。而对于边框,则不显示。请帮助我。

您想导出什么,是翻页还是只导出EmployeeDetails内容?员工详细信息。数据集dsObj=objServiceClient.GetEmployeeList;这就是我所说的服务方法。