使用.net(C#或vb)打印PDF文档 [英] Print PDF Document using .net(C# or vb)

查看:128
本文介绍了使用.net(C#或vb)打印PDF文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim psi As New ProcessStartInfo("C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe")
        psi.UseShellExecute = True
        psi.Verb = "print"
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.FileName = "D:\abc.pdf"
        Process.Start(psi)





i我正在使用此代码从google搜索中找到的vb.net程序打印pdf。但是,当我运行此代码时,它显示没有程序与此过程相关联。。任何人都可以帮我解决问题吗?



i am using this code to print pdf from a vb.net program as found on the googling. but when i run this code it shows "no program is associated with this process".Can any one help me with solution?

推荐答案

ProcessStartInfo("C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe")

使用双引号使VB知道它们之间的字符串。它们工作正常。



当VB将该字符串传递给操作系统时,它会删除双引号(它们只适用于VB中的编程)。这使得字符串显示为由空格分隔的多个字符串: C:\Program ,然后 Files \Adobe\Reader 11.0\Reader\AcroRd32.exe 。这不是一个流程所期望的。



尝试这个

uses double quotes to make VB aware of a string between them. They are working fine.

When VB passes that string to the OS, it removes the double quotes (they are just for programming in VB anyway). That makes the string appear as several strings separated by spaces: C:\Program, then Files\Adobe\Reader and 11.0\Reader\AcroRd32.exe. That's not what a process expects to see.

Try this one

ProcessStartInfo("""C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe""")

最左边的双引号仍然存在。但是在字符串中,有两个加倍的双引号,VB转换为两个双引号,当它传递给操作系统时保留在字符串中。

The outermost double quotes remain. But inside the string, there are two doubled double quotes, which VB translates into two double quotes that remain in the string when it's passed to the OS.


这篇关于使用.net(C#或vb)打印PDF文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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