Ghostscript.NET.dll print pdf to specified printer
如何使用ghostscript api打印pdf。
我尝试了google,但仍未获得适当的解决方案。请帮助我如何完成这项任务。
这应该为您工作(通过使用Ghostscript.NETpackage器):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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); } } } } |