2012-01-20 6 views
1

인쇄 작업 중에 프린터 트레이를 전환 할 수 있습니까? 나는 픽업/팩 슬립 프로그램을 구성하도록 요청 받았다. 재고 픽업 전표를 컬러 용지에 인쇄하고 백지가 흰 종이에 놓이기를 바라며, 올바른 정렬 (픽업, 팩, 팩, 팩, 팩, 픽업, 팩, 팩, 팩, 팩; ...).인쇄 작업 중 프린터 트레이 변경

기본 용지함을 설정할 때 다른 스레드가 발견되었지만 작업 중에 용지함을 번갈아 찾지는 않았습니다. 어쩌면 나는 옳은 것을 찾지 않을거야.

차이가 있는지는 모르겠지만 HP 프린터는 HP 3015n이며 클라이언트는 XP와 Win 7 Pro입니다.

+0

abatishchev - 내 게시물을 편집했습니다. 개발 환경과 프로그래밍 언어는 관련이 없습니까? – Sam

+0

https://www.youtube.com/watch?v=6iXuU4b5mh4&t=25s? :-) – juFo

답변

3

당신은 당신이 프로젝트에서 System.Drawing.dll을 참조 할 필요 이런 식으로 뭔가를 시도 할 수 있습니다.

string _paperSource = "TRAY 2"; // Printer Tray 
string _paperName = "8x17"; // Printer paper name 

//Tested code comment. The commented code was the one I tested, but when 
//I was writing the post I realized that could be done with less code. 

//PaperSize pSize = new PaperSize() //Tested code :) 
//PaperSource pSource = new PaperSource(); //Tested code :) 

/// Find selected paperSource and paperName. 
foreach (PaperSource _pSource in printDoc.PrinterSettings.PaperSources) 
{ 
    if (_pSource.SourceName.ToUpper() == _paperSource.ToUpper()) 
    { 
     printDoc.DefaultPageSettings.PaperSource = _pSource; 
     //pSource = _pSource; //Tested code :) 
     break; 
    } 
} 

foreach (PaperSize _pSize in printDoc.PrinterSettings.PaperSizes) 
{ 
    if (_pSize.PaperName.ToUpper() == _paperName.ToUpper()) 
    { 
     printDoc.DefaultPageSettings.PaperSize = _pSize; 
     //pSize = _pSize; //Tested code :) 
     break; 
    } 
} 

//printDoc.DefaultPageSettings.PaperSize = pSize; //Tested code :) 
//printDoc.DefaultPageSettings.PaperSource = pSource; //Tested code :) 
+0

그래서, 본질적으로 수백 개의 미니 인쇄 작업을 만들고 작업들 사이의 용지 공급원을 바꾸겠습니까? – Sam

+0

시험 할 기회가 없었지만 그것이 효과가 있는지 알았지 만, 내가 스스로 만들어 낸 것보다 더할 수 있습니다. 며칠 만에 아무도 해설하지 않았으므로 나는 답으로 표시 할 것입니다. 감사! – Sam

+1

죄송합니다. 동일한 작업 내에서 트레이를 변경하려고이 접근법을 사용할 수 없습니다. printDoc_PrintPage에서 용지함을 바꿉니다. 그 변화를 무시하는 것처럼 보입니다. – CarneyCode

0

제 지식이 없으면 기본적으로 오직 당신이 사용하는 대기열에 2 개의 작업을 제출해야합니다. > 참조가 - ->

//Namespace: System.Drawing.Printing 
//Assembly: System.Drawing (in System.Drawing.dll) 

PrintDocument printDoc = new PrintDocument(); 
PaperSize oPS = new PaperSize(); 
oPS.RawKind = (int)PaperKind.A4; 
PaperSource oPSource = new PaperSource(); 
oPSource.RawKind = (int) PaperSourceKind.Upper; 

printDoc.PrinterSettings = new PrinterSettings(); 
printDoc.PrinterSettings.PrinterName = sPrinterName; 
printDoc.DefaultPageSettings.PaperSize = oPS; 
printDoc.DefaultPageSettings.PaperSource = oPSource; 
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); 
printDoc.Print(); 
printDoc.Dispose(); 
+0

내가 따라갈 지 모르겠다, 당신은 정교 할 수 있습니까? 감사. – Sam

+0

두 개의 서로 다른 용지함의 용지 종류는 무엇입니까 – MethodMan

+0

Paper Kind의 의미를 확실하지 않습니까? 용지함 1은 8.5x11, 용지함 2는 흰색 8.5x11이됩니다. – Sam

0

당신이 코드를 프린터 트레이를 변경할 수 있습니다 추가

관련 문제