Hii ,
protected void btnExportToExcel_Click(object sender, EventArgs e)
{
WorkingWay3();
WorkingWay3();
}
private void WorkingWay3()
{
HtmlToPdf("http://localhost:32370/User/PerformancePDF.aspx", "D:\\New.pdf");
}
private void HtmlToPdf(string website, string destinationFile)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
startInfo.FileName = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe";
startInfo.Arguments = website + " " + destinationFile;
Process myProcess = Process.Start(startInfo);
myProcess.WaitForExit();
myProcess.Close();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=abc.pdf");
Response.ContentType = "application/pdf";
Response.WriteFile(destinationFile);
Response.End();
}
Above is my code , i am trying to generate multiple pdf files , as my requirement is there can be multiple pdf with differnt differnt page , i tried to call same method twice , but it gets called only once , and give me single pdf document ..
I also tried to use for loop by giving differnt website path , but again it gets called only once , in this i comment last line that is respond.end to debug .. but then it calls multiple times for loop , but at last only single pdf generated ..
Please suggest