2013-01-09 8 views
0

프린터 작업을 가로 채서 인쇄 작업의 특성을 변경하려고합니다. 인쇄 작업을 가로 채서 정보를 얻습니다. 나는 인쇄 작업의 용지 크기를 변경하려면 이제C에서 PrintCapabilities 클래스를 사용하는 방법

http://www.codeproject.com/Questions/423178/printing-order-intercept-with-csharp

이 문서를 다음과 그것을 위해 나는이 문서

http://social.msdn.microsoft.com/Forums/en/windowsxps/thread/8af6ba92-5d2c-444b-91f4-a8747739c1b7

을 발견하지만 문제는 내가 만들 수 없다 PrintCapabilities 클래스입니다. 나는 무엇인가 놓치고 있냐?? 도와주세요.

나의 현재 코드는 다음과 같습니다 : 나는 실제로 답을 발견

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Management; 
using System.Printing; 

namespace PrintJob 
{ 
    class EvenWatch 
    { 
     private ManagementEventWatcher manEWatch; 

     public EvenWatch(string host) 
     { 

      System.Management.ManagementScope oMs = new System.Management 
      .ManagementScope(@"\\" + host + @"\root\cimv2"); 
      oMs.Connect(); 
      manEWatch = new ManagementEventWatcher(oMs, new EventQuery("SELECT * FROM __InstanceCreationEvent WITHIN 0.1 WHERE TargetInstance ISA 'Win32_PrintJob'")); 



      manEWatch.EventArrived += new EventArrivedEventHandler(
      mewPrintJobs_EventArrived); 
      manEWatch.Start(); 
     } 

     static void mewPrintJobs_EventArrived(object sender, EventArrivedEventArgs e) 
     { 
      foreach (PropertyData prop in e.NewEvent.Properties) 
      { 
       string val = prop.Value == null ? "null" : prop.Value.ToString(); 

      } 

      ManagementBaseObject printJob = (ManagementBaseObject)e.NewEvent.Properties["TargetInstance"].Value; 
      string v = ""; 
      foreach (PropertyData propp in printJob.Properties) 
      { 
       string name = propp.Name; 
       string val = propp.Value == null ? "null" : propp.Value.ToString(); 
       val += "\n"; 
       v += name + ":" + val; 

      } 

      PrintQueue printerSpooler = null; 
      printerSpooler = new PrintQueue(new PrintServer(), "EPSON LQ-300+ /II ESC/P 2"); 
      PrintJobSettings printJobSetting = printerSpooler.CurrentJobSettings; 
      string desc = printJobSetting.Description; 



      //printerSpooler.CurrentJobSettings.CurrentPrintTicket 

      Console.WriteLine("-------"); 
      Console.WriteLine(v); 
     } 
    } 
} 
+0

코드는 어떻게 생겼습니까? –

답변

1

. 4.0을 사용하는 경우 ReachFramework.dll을 참조하면 마술이 발생합니다.

+0

감사합니다. 이걸 찾으러 잠시 나갔어. – OrahSoft

관련 문제