0

私はこのコードを使用して単語文書を生成しようとします:

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();

このワード文書をプログラムでPDFファイルに変換する方法を知っている人はいますか?

4

3 に答える 3

1

変換するHTMLを作成しているので、iTextSharp APIを使用してHTMLからPDFに移行できます:ITextSharp HTMLからPDF?。iTextSharpは無料です。

于 2012-07-12T08:30:22.177 に答える
0

MS .Net Frameworkはデフォルトでは何も提供しませんが、サードパーティAPIを使用する必要があります

たとえば、API easyPDFがC#を使用して変換を行うリンクを参照して くださいhttp://www.pdfonline.com/easypdf/sdk/programming-pdf/csharp/index.htm?_kk=%2Bpdf%20%2Bc%23&_kt=0e3c1bed-3404 -4289-8143-77333a737850&gclid = CPT--pXTk7ECFa4mtAodKn5ylw

于 2012-07-12T07:51:22.600 に答える
0

多くの異なるオプションを使用した後、これは私たちが見つけた最高のものでした。高価ですが、驚くべき速度と汎用性、まともな(優れているわけではありませんが)サポートドキュメントがあります。 http://www.html-to-pdf.net/Support.aspx#csharp-コストを転嫁できる商用プロジェクトの場合は、一見の価値があります。

于 2012-07-12T08:38:43.277 に答える