2013-04-12 4 views
0

C#으로 XPS 파일을 인쇄하려고합니다. XPS 파일을 바이트 스트림으로 가져옵니다. 나는 PrintQueue 클래스에서 제공하는 다른 AddJob 방법과이를 달성하기 위해 노력하고 이것은 바이트 스트림을 허용하고 인쇄를 다음과 같은 문제를 바이트 스트림에서 XPS 파일 인쇄

  • AddJob(String)

가 발생했습니다. 그러나이 방법은 파일 스풀링을 오래 동안 유지하므로 사용할 수 없습니다. AddJob(String, PrintTicket)

  • 는 XPS 파일의 실제 파일 위치를 요구했다. 내 파일이기 때문에 바이트 스트림이 방법은 또한 실제 파일 위치

    • AddJob(String, String, Boolean, PrintTicket)

    을 필요로 이것

    • AddJob(String, String, Boolean)

    를 사용할 수없는 것은 실제 파일 위치를 필요

    그러므로 바이트 스트림에서 XPS 파일을 인쇄하는 방법은 무엇입니까? - 새로운 (일반적으로 이름) 인쇄 작업을 삽입, 내용이 Byte 배열입니다

    AddJob() :이

답변

1

에 대한 모든 제 3 자 라이브러리를 사용하지 않으 가지고 다음과 같은 과부하를 시도 , 대기열에.

// Create the printer server and print queue objects 
LocalPrintServer localPrintServer = new LocalPrintServer(); 
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue(); 

// Call AddJob 
PrintSystemJobInfo myPrintJob = defaultPrintQueue.AddJob(); 

// Write a Byte buffer to the JobStream and close the stream 
Stream myStream = myPrintJob.JobStream; 
Byte[] myByteBuffer = UnicodeEncoding.Unicode.GetBytes("This is a test string for the print job stream."); 
myStream.Write(myByteBuffer, 0, myByteBuffer.Length); 
myStream.Close(); 
다음과 같이 MSDN으로부터 얻어진 몇 가지 샘플 코드는