【问题标题】:VB.net - print pdf file with printer with paper sizeVB.net - 使用具有纸张大小的打印机打印 pdf 文件
【发布时间】:2016-04-09 19:18:52
【问题描述】:

我正在构建一个主要功能是打印 .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 reader,但是否有更好的打印方法?我愿意接受建议!

请帮忙..我卡住了!!


我也在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进程?

【问题讨论】:

标签: c# vb.net pdf printing


【解决方案1】:

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

  1. 获取您的 PDF 文件的完整路径:

     String fullpath =System.IO.Path.GetFullPath(@FilePath);
    
  2. 使用默认 PDF 阅读器打开它:

    Process.Start(@fullpath);
    

【讨论】:

    猜你喜欢
    • 2014-03-16
    • 2012-08-31
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 2017-11-26
    • 2016-07-29
    • 2010-11-13
    • 1970-01-01
    相关资源
    最近更新 更多