【问题标题】:Ghostscript.NET.dll print pdf to specified printerGhostscript.NET.dll 打印pdf到指定打印机
【发布时间】:2015-02-03 13:42:14
【问题描述】:

如何使用 ghostscript api 打印 pdf。 我尝试了谷歌,但仍然没有得到正确的解决方案。请帮助我如何完成这项任务。

【问题讨论】:

标签: c# vb.net winforms ghostscript ghostscript.net


【解决方案1】:

这应该对你有用(通过使用Ghostscript.NET 包装器):

using System;
using System.Collections.Generic;
using Ghostscript.NET.Processor;

namespace Ghostscript.NET.Samples
{
    public class SendToPrinterSample : ISample
    {
        public void Start()
        {
            // YOU NEED TO HAVE ADMINISTRATOR RIGHTS TO RUN THIS CODE

            string printerName = "YourPrinterName";
            string inputFile = @"E:\__test_data\test.pdf";

            using (GhostscriptProcessor processor = new GhostscriptProcessor())
            {
                List<string> switches = new List<string>();
                switches.Add("-empty");
                switches.Add("-dPrinted");
                switches.Add("-dBATCH");
                switches.Add("-dNOPAUSE");
                switches.Add("-dNOSAFER");
                switches.Add("-dNumCopies=1");
                switches.Add("-sDEVICE=mswinpr2");
                switches.Add("-sOutputFile=%printer%" + printerName);
                switches.Add("-f");
                switches.Add(inputFile);

                processor.StartProcessing(switches.ToArray(), null);
            }
        }
    }
}

【讨论】:

  • 我在没有安装幽灵脚本的情况下尝试了以下建议的链接代码。我尝试使用 gsdll32.dll 程序集二进制文件和 GhostscriptVersionInfo。 link 请帮助我如何使用本机 dll 和托管程序集。
  • 当打印机移除它时 processor.StartProcessing(switches.ToArray(), null);方法卡住了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-27
  • 2013-09-09
  • 2011-02-22
  • 2013-07-31
  • 1970-01-01
  • 2016-06-02
  • 2017-05-24
相关资源
最近更新 更多