A
A
Andrew2015-08-01 13:49:43
WPF
Andrew, 2015-08-01 13:49:43

How to set up WPF printing: number of copies, printer selection, orientation?

I can print, but I can't set up the printer.
Namely, these lines give an error:

//определение принтера
printDialog.PrintQueue = GetPrintQueues();
          //Количество копий
          printDialog.PrintTicket.CopyCount = 3;
          printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;

b07517c955d0447c85d20f05ee74a2e8.png
Here is the whole code:
private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();

          //определение принтера
         // printDialog.PrintQueue = GetPrintQueues();
          //Количество копий
        //  printDialog.PrintTicket.CopyCount = 3;
          //printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;


               if (printDialog.ShowDialog() == false)
           {
               //Определить поля
               int pageMargin = 10;

               //Получить размер страници
               Size pageSize = new Size(printDialog.PrintableAreaWidth - pageMargin * 2, printDialog.PrintableAreaHeight * 20);

               //Инициировать установку размера элемента
               canvas.Measure(pageSize);
               canvas.Arrange(new Rect(pageMargin, pageMargin, pageSize.Width, pageSize.Height));

               //Напечатать элемент
               printDialog.PrintVisual(canvas, "Распечатать элемент Canvas");
           }
            
        }

What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kestik, 2015-08-02
@Kaspel

In your screenshot, it says white on black: you need to add a link to System.Printing and ReachFramework.
https://msdn.microsoft.com/en-us/library/wkze6zky%...
Subtitle "To add a link in Visual C#"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question