Compartir a través de


Cómo: Crear y mostrar un objeto PrintDialog

Actualización: noviembre 2007

En este ejemplo se indica cómo mostrar un cuadro PrintDialog.

Ejemplo

En el ejemplo siguiente se indica cómo mostrar un cuadro de diálogo de impresión por medio de estos pasos:

<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");
        }
    }

Para obtener el ejemplo completo, vea Ejemplo PrintDialog.

Vea también

Referencia

PrintDialog