问题描述
我要生成服务器端的PDF文件,然后在响应要发送的文件(缓冲,fileName-任何可能工作),并显示一个打印对话框询问用户打印生成的PDF文件。
I want to generate a PDF file on server side, and then in response want to send that file (buffer,fileName- whatever may work) and show a print dialog to ask user to print the generated PDF file.
我想是这样的下方。不过,这并不触发window.print()对话框。
I tried something like below. But it does not trigger window.print() dialog.
public static void ForcedPrint(HttpResponse response, byte[] buffer, string fileName, string fileExtension) {
response.Clear();
response.Buffer=true;
response.Write("<script>window.print();</script>");
response.Charset="";
response.Cache.SetCacheability(HttpCacheability.NoCache);
response.ContentType="application/pdf";
response.BinaryWrite(buffer);
response.Flush();
response.End();
}
可有人请帮助我?
的功能我期待的是,我应该能够创建在服务器上的PDF文件,并针对用户应该得到一个对话框来打印生成的文件。
Can someone please help me with this?The feature i am looking for is that i should be able to create PDF file on server, and in response user should get a dialog to print the generated file.
在此先感谢。
推荐答案
您需要嵌入PDF中的HTML文档中说,在一个名为DIV thePDF
,并在文件中的JavaScript代码,你需要调用
You need to embed the PDF in the HTML document, say in a div called thePDF
and in JavaScript code in the document, you need to invoke
thePDF.printWithDialog()
这似乎将是的Adobe Reader插件的打印对话框,而不是浏览器的打印对话框中的对话框;这将允许在打印前的页面等选择。
The dialog that appears will be the Adobe Reader plugin's print dialog rather than the browser's print dialog; this will allow selection of pages etc. before printing.
这篇关于如何触发服务器端(asp.net)Windows打印对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!