【发布时间】:2017-02-03 21:45:47
【问题描述】:
我想在 .net core 中进行打印。
为此,我使用Process 或System.Diagnostics。
我尝试了以下代码:
var printJob = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = path,
UseShellExecute = true,
Verb = "print",
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = Path.GetDirectoryName(path)
}
};
但是 .net 核心中的 StartInfo 中缺少 Verb 属性。
所以我决定按如下方式打印:
Process.Start("LPR -S ip -P 'Star TSP800L Peeler (TSP828L)' -o 'D:\testpdf.pdf'");
但它给了我
系统找不到指定的文件
而文件存在于给定位置。
现在我正在尝试在我的 windows 10 机器上使用本地打印机进行测试,但我需要从 ubuntu 机器打印到网络打印机。
谁能告诉我,为什么我会收到找不到文件的错误。 我找到了以下链接,但它使用的是 StartInfo,在这种情况下对我没有帮助。
Process.Start in C# The system cannot find the file specified error
Error in Process.Start() -- The system cannot find the file specified
【问题讨论】:
-
现在当我打印到本地打印机时,我得到打印服务器无法访问或指定的打印机不存在错误?我正在使用以下命令:lpr -S my_machine_ip -P Star TSP800L Peeler (TSP828L) -o l D:\\testpdf.pdf
标签: c# asp.net-core asp.net-core-mvc .net-core asp.net-core-webapi