我尝试使用以下代码生成 word 文档:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/doc";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;
filename=" + DateTime.Now + ".doc");
var strHTMLContent = new StringBuilder();
strHTMLContent.Append(
"<h1 title='Heading' align='Center'style='font-family: verdana; font
-size: 80 % ;color: black'><u>Document Heading</u> </h1> ");
strHTMLContent.Append("<br>");
strHTMLContent.Append("<table align='Center'>");
// Row with Column headers
strHTMLContent.Append("<tr>");
strHTMLContent.Append("<td style='width:100px; background:# 99CC00'>
<b>Column1 </b> </td>");
strHTMLContent.Append("<td style='width:100px;background:# 99CC00'>
<b>Column2 </b> </td>");
strHTMLContent.Append("<td style='width:100px; background:# 99CC00'>
<b>Column 3</b></td>");
strHTMLContent.Append(" </tr> ");
// First Row Data
strHTMLContent.Append("<tr>");
strHTMLContent.Append(
"<td style='width:100px'></td>");
strHTMLContent.Append(
"<td style='width:100px'>b</td>");
strHTMLContent.Append(
"<td style='width:100px'>c</td>");
strHTMLContent.Append("</tr>");
// Second Row Data
strHTMLContent.Append("<tr>");
strHTMLContent.Append(
"<td style='width:100px'>d</td>");
strHTMLContent.Append(
"<td style='width:100px'>e</td>");
strHTMLContent.Append(
"<td style='width:100px'>f</td>");
strHTMLContent.Append("</tr>");
strHTMLContent.Append("</table>");
strHTMLContent.Append("<br><br>");
strHTMLContent.Append(
"<p align='Center'> Note : This is a dynamically
generated word document </p> ");
HttpContext.Current.Response.Write(strHTMLContent);
// HttpContext.Current.Response.BinaryWrite(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
有谁知道如何以编程方式将此word文档转换为PDF文件?