首页 文章

VB.net - 使用纸张大小的打印机打印pdf文件

提问于
浏览
0

我正在构建一个主要功能是打印.pdf文件的应用程序 . 我经常搜索,找不到我需要的东西,所以这是我的问题 .

我想创建一个方法,打印带有选定打印机和纸张大小的.pdf文件 . (我们有一个绘图仪,它来自A0 - A3图纸)因此可以批量 生产环境 不同尺寸的大范围 .

Public Sub print_pdf(byval document as string, byval printer as string, byval size as string)

我找到了这个类似的帖子,但是......它是用 c# 编写的,我只能熟悉vb.net .

Link to post

我们所有的PC都配备了acrobat阅读器,但是如果有更好的打印方法吗?我愿意接受建议!

请帮忙..我被卡住!!


我在 c# 找到了这个示例代码

string path = "" <- your path here.
    if (path.EndsWith(".pdf"))
        {
            if (File.Exists(path))
            {
                ProcessStartInfo info = new ProcessStartInfo();
                info.Verb = "print";
                info.FileName = path;
                info.CreateNoWindow = true;
                info.WindowStyle = ProcessWindowStyle.Hidden;
                Process p = new Process();
                p.StartInfo = info;
                p.Start();
                p.WaitForInputIdle();
                System.Threading.Thread.Sleep(3000);
                if (false == p.CloseMainWindow())
                    p.Kill();
            }
        }

来自this帖子 . 有没有办法闲置直到打印队列完成?然后打印一个kill进程?

1 回答

  • 0

    您可以使用默认PDF阅读器,如Acrobat或FoxitReader,打开文件然后打印它,这很简单 . 这是C#代码:

    • 获取PDF文件的完整路径:
    String fullpath =System.IO.Path.GetFullPath(@FilePath);
    
    • 使用默认PDF阅读器打开它:
    Process.Start(@fullpath);
    

相关问题