2012-03-16 2 views
1

.Net을 통해 Microsoft XPS Document Writer가 사용 가능하고 작동하는지 확인할 수있는 확실한 방법이 있습니까?Microsoft XPS Document Writer가 사용 가능하고 시스템에서 작동하는지 확인하는 방법이 있습니까

또한 XPS Writer의 이름은 모든 Windows 배포에서 동일합니까 (예 : 영어, 독일어 (...))?

Vista 이후 모든 Windows 시스템에서 XPS Writer를 사용할 수 있습니까? 또한 Starter Editions, 모든 x86 및 x64 Edition 및 Windows 8에서도?

+1

이름은 확실히 신뢰할 수 없습니다. 사용자는 언제든지 "Microsoft XPS Document Writer"인쇄 큐의 이름을 바꿀 수 있습니다. – Jon

답변

0

나는 당신이 작동하지 않는 다음 경우, 시도하고 XPS를 인쇄하려면 아래의 조각을 사용할 수 있습니다 의심 http://msdn.microsoft.com/en-us/library/aa969772.aspx

한 번 봐, 당신은 아마 프린터가 없습니다.

피터 Witvoet에 의해 제안
  try 
      { 
       // Print the Xps file while providing XPS validation and progress notifications. 
       PrintSystemJobInfo xpsPrintJob = defaultPrintQueue.AddJob(f.Name, nextFile, false); 
      } 
      catch (PrintJobException e) 
      { 
       Console.WriteLine("\n\t{0} could not be added to the print queue.", f.Name); 
       if (e.InnerException.Message == "File contains corrupted data.") 
       { 
        Console.WriteLine("\tIt is not a valid XPS file. Use the isXPS Conformance Tool to debug it."); 
       } 
       Console.WriteLine("\tContinuing with next XPS file.\n"); 
      } 
+0

링크가 끊어졌습니다. – AXMIM

1

"프린터"의 모델도 Microsoft XPS Document Writer이며 그 이름은 동일하게 유지됩니다.

해당 모델로 프린터를 찾을 수 있습니다.

+1

실제로 모델은 PrintQueue.QueueDriver.Name을 통해 얻을 수있는 프린터 드라이버의 이름 인 것 같습니다. –

0

는 여기 XPSPrinter 드라이버 이름에 따라 설치하거나되지 않은 경우 반환하는 방법입니다.

이 방법은 프린터를 찾을 때까지 프린터를 반복하거나 찾지 않고 매 스캔마다 스캔합니다. "System.Management"에 대한 참조가 프로젝트에 추가되어야합니다.

private bool GetIfXPSPrinterIsInstalled() 
    { 
     bool isXPSPrinterMissing = true; 
     try 
     {    
      var printerQuery = new System.Management.ManagementObjectSearcher("SELECT * from Win32_Printer"); 
      var iterator = printerQuery.Get().GetEnumerator(); 
      while (iterator.MoveNext() && isXPSPrinterMissing) 
      { 
       //isXPSPrinterMissing = iterator.Current.GetPropertyValue("DriverName").ToString() != "Microsoft XPS Document Writer"; 
       isXPSPrinterMissing = !iterator.Current.GetPropertyValue("DeviceID").ToString().ToUpper().Contains("XPS"); 
      } 
      if (isXPSPrinterMissing) 
      { 
       MessageBox.Show("Warning, there is no XPS printer installed on this computer"); 
      } 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show("System couldn't verify if there is a XPS printer installed because an error occured");    
     } 
     return !isXPSPrinterMissing; 
    } 

편집 : 내가 발견 해당 드라이버 이름은 약간의 시간이 잘못 될 수 있습니다. XPS 프린터 및 일부 비 xps 프린터 대신 "원격 데스크톱 간편 인쇄"가 될 수 있습니다. 따라서 DeviceID에 XPS가 포함되어 있는지 확인하는 것이 더 안전한 방법입니다.

관련 문제