0

wkhtmltopdfASP.NETでHTMLページをPDFに変換するために使用しています。以下は私のコーディングです

protected void Button_Click(object sender, EventArgs e)
{
    Process p = new Process();
    p.StartInfo = new ProcessStartInfo();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = Server.MapPath("~/wkhtmltopdf/wkhtmltopdf.exe");
    string arguments = "\"" + "http://localhost:51528/settings/InvoiceStatementPrint.aspx?InvoiceID=48\"" + " " + Server.MapPath("~/settings/" + "InvoiceDetail_1.pdf");
    p.StartInfo.Arguments = arguments;
    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    p.StartInfo.CreateNoWindow = true;
    p.Start();
    p.WaitForExit();
    p.Close();
    p.Dispose();
}

URL は適切なページを作成します。ただし、 InvoiceDetail_1.pdf黒いページの PDF が生成されます。私のコードに何か問題がありますか?

4

1 に答える 1

0

コードに問題はありません。問題は入力 HTML にあります。ツールをスタンドアロンで実行してみてください。同じ結果が得られます。

余談ですが、TuesPechkinは、.NET から wkhtmltopdf を呼び出す簡単な方法を提供します。

于 2015-03-11T11:46:53.437 に答える