发送MVC的ActionResult打印机 [英] Send MVC actionresult to printer
问题描述
我有一个动作控制器:
SomeController/ActionToBePrinted
ActionToBePrinted()返回一个HTML视图。
ActionToBePrinted() returns an html view.
此操作是从一个正常的MVC剃刀视图调用时pressing一个按钮 - ?我将如何去有关发送视图的内容到打印机按钮时,pressed
This action is called from a normal mvc razor view when pressing a button - how would I go about sending the content of the view to a printer when the button is pressed?
阿罗哈, 雨果
推荐答案
您不能直接发送到打印机。
You cant send direct to the printer.
-
我建议你创建一个自定义的ActionResult,它返回一个PDF文件或类似的东西。 ASP.NET MVC行动结果和PDF内容
您可以显示一个HTML页面,以及和使用JavaScript这样打开打印对话框
You can show a html page as well and open the print dialog using javascript like this
< A HREF =JavaScript的:window.print()>点击打印本页< / A>
但始终是用户必须开始打印过程,你不能以编程方式做到这一点。
But always the user has to start the print process, you cant do this programmatically.
这篇关于发送MVC的ActionResult打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!