Пример #1
0
        private void PrintClick(object sender, RoutedEventArgs e)
        {
            var printDialog = new PrintDialog();
            if (printDialog.ShowDialog() != true) return;

            var paginator = new Paginador(new ServicoDados().ObterClientes(),
                                                new Size(printDialog.PrintableAreaWidth,
                                                printDialog.PrintableAreaHeight));
            printDialog.PrintDocument(paginator, "Impressão Wpf");
        }
Пример #2
0
 private void PreviewClick(object sender, RoutedEventArgs e)
 {
     var printDialog = new PrintDialog();
     var paginator = new Paginador(new ServicoDados().ObterClientes(),
                                         new Size(printDialog.PrintableAreaWidth,
                                         printDialog.PrintableAreaHeight));
     using (var xpsDocument = new XpsDocument(Path.GetRandomFileName(), FileAccess.ReadWrite))
     {
         var writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
         writer.Write(paginator);
         var previewWindow = new PrintPreview
         {
             Document = xpsDocument.GetFixedDocumentSequence()
         };
         previewWindow.ShowDialog();
     }
 }