HOW TO PRINT VISUALIZATION AS GRAYSCALE WPF?

john rob

Total Post:108

Points:756
Posted by  john rob
WPF 
C#
 1330  View(s)
Ratings:
Rate this:

How can I print a visual as grayscale without actually showing the PrintDialog, e.g.

PrintDialog dialog = new Dialog();
dialog.PrintQueue = new PrintQueue(new PrintServer(), printerNameAsString);
dialog.PrintTicket.InputBin = InputBin.AutoSelect;
// Further settings, e.g. PageMediaSize and scaling the visual.    

dialog.PrintVisual(myVisual, "myDescription");

Can I somehow get the PrinterDialog to print the visual in grayscale? Or is there a completely other way to achieve a grayscale printout of my visual?

Edit: myVisual (the Visual I want to print) is a Grid, so it inherits from UIElement. Edit 2: If possible I would prefer not to use any external libraries (because of company policies).

  1. Manoj Bhatt

    Post:154

    Points:1086
    Re: How to Print visualization as grayscale WPF?

    In the PrintDialog the OutputColor can be set:


    myPrintDialog.PrintTicket.OutputColor
    = OutputColor.Grayscale;
    Also, the PrintCapabilities make it possible to actually check which OutputColors are possible:

    PrintCapabilities
    capabilities =
    myPrintDialog.PrintQueue.GetPrintCapabilities(myPrintDialog.PrintTicket);
                ReadOnlyCollection<OutputColor> possibleColors = capabilities.OutputColorCapability;

    On the hardware available to me this works fine.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!