我创建了一个应用程序,它将根据C#中的用户选择运行sql脚本,我使用pdfcrowd将页面打印为PDF。当用户用户访问该页面时,他们将该图表视为“新状态”。在进行选择后,列Dataset 1
和Dataset 2
中的单元格将填充平均值。当我点击我的打印按钮时,而不是显示页面处于“当前状态”的pdf;它反而将其打印出来,就好像用户没有选择一样,但.net页面保留了用户选择的信息。如何以当前状态打印页面?这是我的打印功能代码:
System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
try
{
// create an API client instance
pdfcrowd.Client client = new pdfcrowd.Client("userid", "appID");
// convert a web page and write the generated PDF to a memory stream
MemoryStream Stream = new MemoryStream();
client.convertURI("http://www.somelinksomewhere.com", Stream);
client.setPageWidth("8.5in");
// set HTTP response headers
Response.Clear();
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Cache-Control", "max-age=0");
Response.AddHeader("Accept-Ranges", "none");
Response.AddHeader("Content-Disposition", "attachment; filename=my_nonworking.pdf");
// send the generated PDF
Stream.WriteTo(Response.OutputStream);
Stream.Close();
Response.Flush();
Response.End();
}
catch (pdfcrowd.Error idunno)
{
Response.Write(idunno.ToString());
}