私のアプリケーションでは、学生はすべての詳細を入力してから、送信ボタンをクリックします。
StudentDetails.aspx ページに学生のすべての詳細が表示されます。
studentDetails.aspx ページには、[印刷] ボタンがあります。
私が望むのは、学生がこの印刷ボタンをクリックすると、学生の詳細が PDF ファイル形式で表示され、印刷できるようになることです。
私は次のことを試しました。誰かが私がこれから抜け出すのを手伝ってくれます...`
protected void Button1_Click(object sender, EventArgs e)
{
Uri strurl = Request.Url;
string url = strurl.ToString();
string filename = "Test";
HtmlToPdf(url, filename);
}
public static bool HtmlToPdf(string Url, string outputFilename)
{
string filename = ConfigurationManager.AppSettings["ExportFilePath"] + "\\" + outputFilename + ".pdf";
Process p = new System.Diagnostics.Process();
p.StartInfo.Arguments = Url + " " + filename;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = HttpContext.Current.Server.MapPath(@"C:\Users\$$\Documents\Visual Studio 2008\Projects\santhu") + "wkhtmltopdf.exe";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit(60000);
int returnCode = p.ExitCode;
p.Close();
return (returnCode == 0 || returnCode == 2);
}
}