Windows 8的打击上打印PDF文件时,如何C#程序错误? [英] Windows 8 blows error on c# process for printing pdf file, how?

查看:520
本文介绍了Windows 8的打击上打印PDF文件时,如何C#程序错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码至少完美的作品打印在Windows 7中的PDF文件,但在Windows 8中吹了一个错误:

The following code at least works perfectly printing a pdf file in Windows 7, but is blowing an error in 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();

下面是错误的一些细节:

Here are some details of the error:

************** 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)

我知道有一个Adobe阅读器PDF文件反正但我坚持的是什么,我需要获得工作在Windows 8让这个错误不会再次发生。

I know there's an adobe reader for pdf files anyways but am stuck as to what I need to get working on Windows 8 so this error doesn't happen again.

编辑,现在这是怪异的在Windows 8中:
printto不被识别为一个内部或外部命令

edit, now this is weird in Windows 8: printto is not recognized as an internal or external command

我试着谷歌上搜索这个但我惊呆了没有结果上来。
所有我想要做的就是programmically打印文档到一个特定的打印机。

I tried googling this but am shocked no results come up. All I want to do is programmically print my document to a specific printer.

推荐答案

该错误消息告诉大家你得知道。有对.pdf文件扩展名printto动词定义什么。你需要配置你的文件关联来弥补,如果你想这种方式工作。

The error message tells you all you need to know. There is nothing defined for the printto verb on the .pdf file extension. You'll need to configure your file associations to remedy that if you want this approach to work.

您正试图做到这一点是非常脆弱,依赖,因为它确实对第三方PDF阅读器的vagueries的方式。如果你控制所有在运行应用程序的机器,你可以随意配置PDF阅读器。否则,你可以期望处理大量的客户支持。一个更强大的解决方案是建立PDF打印功能到使用的许多库提供这种功能的一个应用程序。

The way you are attempting to do this is pretty brittle, relying as it does on the vagueries of a third party PDF viewer. If you control all the machines on which the application runs, you can configure the PDF viewer as you like. Otherwise you can expect to deal with a lot of customer support. A more robust solution would be to build the PDF printing capability into your application using one of the many libraries that offer such capabilities.

这篇关于Windows 8的打击上打印PDF文件时,如何C#程序错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆