gpt4 book ai didi

c# - Windows 8 在打印 pdf 文件的 c# 过程中出现错误,怎么办?

转载 作者:太空宇宙 更新时间:2023-11-03 16:08:40 24 4
gpt4 key购买 nike

以下代码至少可以在 Windows 7 中完美地打印 pdf 文件,但在 Windows 8 中会报错:

                Process process = new Process();
//process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.FileName = defFile;
if (rwPrinter.Length > 0)
{
process.StartInfo.Verb = "printto";
process.StartInfo.Arguments = "\"" + rwPrinter + "\"";
}
else
{
process.StartInfo.Verb = "print";
}
process.Start();

以下是错误的一些详细信息:

************** Exception Text **************
System.ComponentModel.Win32Exception (0x80004005):
No application is associated with the specified file for this operation
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at ECitation.Form1.process_ticket(String jobdo)
at ECitation.Form1.btnPrint_Click(Object sender, EventArgs e)

我知道无论如何有一个用于 pdf 文件的 adobe 阅读器,但我不知道我需要什么才能在 Windows 8 上工作,所以这个错误不会再次发生。

编辑,现在这在 Windows 8 中很奇怪:printto 不被识别为内部或外部命令

我尝试用谷歌搜索这个,但很震惊没有结果。我只想通过编程将我的文档打印到特定打印机。

最佳答案

错误消息告诉您所有您需要知道的。没有为 .pdf 文件扩展名上的 printto 动词定义任何内容。如果您希望此方法起作用,则需要配置文件关联来解决这个问题。

您尝试执行此操作的方式非常脆弱,因为它依赖于第三方 PDF 查看器的模糊性。如果您控制运行该应用程序的所有机器,您可以根据需要配置 PDF 查看器。否则,您可能需要处理大量的客户支持。一个更强大的解决方案是使用提供此类功能的众多库之一将 PDF 打印功能构建到您的应用程序中。

关于c# - Windows 8 在打印 pdf 文件的 c# 过程中出现错误,怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18320704/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com