C# 응용 프로그램에서 화면에 진행 대화 상자가 나타나지 않고 인쇄 미리보기를 생성하려고합니다.인쇄 미리보기를 수행 할 때 인쇄 진행 대화 상자가 나타나지 않도록하려면 어떻게해야합니까?
사실 (인쇄 미리보기가 아님) 인쇄 할 때 이것을 방지하기 위해 PrintDocument.PrintController을 사용할 수는 있지만 인쇄 미리보기를 수행 할 때는 작동하지 않는 것으로 보입니다. 다음과 같이
내 코드는 다음과 같습니다
public FrmDeliveryNotePrintPreview(DeliveryNote deliveryNote)
{
InitializeComponent();
this.Text = "Delivery Note #" + deliveryNote.Id.ToString();
// The print preview window should occupy about 90% of the
// total screen height
int height = (int) (Screen.PrimaryScreen.Bounds.Height * 0.9);
// Making an assumption that we are printing to A4 landscape,
// then adjust the width to give the correct height:width ratio
// for A4 landscape.
int width = (int) (height/1.415);
// Set the bounds of this form. The PrintPreviewControl is
// docked, so it should just do the right thing
this.SetBounds(0, 0, width, height);
PrinterSettings printerSettings = new PrinterSettings();
PrintDeliveryNotes pdn = new PrintDeliveryNotes(
new DeliveryNote[] { deliveryNote },
printerSettings);
PrintDocument printDocument = pdn.PrintDocument;
printDocument.PrintController = new PreviewPrintController();
ppcDeliveryNote.Document = printDocument;
}
인쇄 미리보기가 떨어져 인쇄 미리보기 진행 대화 상자가 표시됩니다 사실에서, 내가 원하는대로 정확하게 작동합니다.
제안 사항을 알려주십시오.
PrintDeliveryNotes는 배달 정보 배열을 인쇄하는 클래스입니다. 이 경우에는 Print() 메서드를 호출하지 않고 단순히 PrintDocument 속성을 검색하고이를 사용자 지정 폼의 PrintPreviewControl에 제공합니다. – Bryan