Share via


방법: PrintDialog 만들기 및 표시

업데이트: 2007년 11월

이 예제에서는 PrintDialog 상자를 표시하는 방법을 보여 줍니다.

예제

다음 예제에서는 다음과 같은 방법을 통해 인쇄 대화 상자를 표시하는 방법을 보여 줍니다.

<Button Width="200" Click="InvokePrint">Invoke PrintDialog</Button>

...

private void InvokePrint(object sender, RoutedEventArgs e)
    {
        // Create the print dialog object and set options
        PrintDialog pDialog = new PrintDialog();
        pDialog.PageRangeSelection = PageRangeSelection.AllPages;
        pDialog.UserPageRangeEnabled = true;

        // Display the dialog. This returns true if the user presses the Print button.
        Nullable<Boolean> print = pDialog.ShowDialog();
        if (print == true)
        {
            XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
            FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
            pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
        }
    }

전체 샘플을 보려면 PrintDialog 샘플을 참조하십시오.

참고 항목

참조

PrintDialog