locked
How to get default options in device app for printers

    Question

  • Hello everyone,
    In some cases, I need reset some features to default value in device app for printers.
    Is there any API can get default Option for the specified feature?

    Thanks

    Monday, January 06, 2014 1:11 PM

Answers

  • Hi MinscBoo,

    Thank you for a clarify and sorry for a late reply. Take a look at the sample http://code.msdn.microsoft.com/windowsapps/Print-Sample-c544cce6, in scenario three, you would find the setting part for PageMediaSize

    IList<string> displayedOptions = printTask.Options.DisplayedOptions;
    
                                                          // Choose the printer options to be shown.
                                                          // The order in which the options are appended determines the order in which they appear in the UI
                                                          displayedOptions.Clear();
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.MediaSize);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Collation);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Duplex);
    
                                                          // Preset the default value of the printer option
                                                          printTask.Options.MediaSize = PrintMediaSize.NorthAmericaLegal;
    
                                                          // Print Task event handler is invoked when the print job is completed.
                                                          printTask.Completed += async (s, args) =>
                                                          {
                                                              // Notify the user when the print operation fails.
                                                              if (args.Completion == PrintTaskCompletion.Failed)
                                                              {
                                                                  await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                                                  {
                                                                      rootPage.NotifyUser("Failed to print.", NotifyType.ErrorMessage);
                                                                  });
                                                              }
                                                          };
    
                                                          sourceRequestedArgs.SetSource(printDocumentSource);

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, January 10, 2014 7:03 AM
    Moderator

All replies

  • Hi MinscBoo,

    Default option for specified feature, what kind of specified feature you need? Not sure if I understand your question clearly but take a look at Windows.Graphics.Printing.OptionDetails. should help.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, January 07, 2014 2:14 AM
    Moderator
  • Hi Jamles Hez,
    Thank you for your reply.

    >what kind of specified feature you need?
    I need Print Schema Features like PageMediaSize and DocumentDuplex in the advanced print settings flyout.

    Also, Windows.Graphics.Printing.OptionDetails doesn't work because PrintManager.GetForCurrentView() throws an exception in the advanced print settings flyout.
    Tuesday, January 07, 2014 2:55 PM
  • Hi MinscBoo,

    Thank you for a clarify and sorry for a late reply. Take a look at the sample http://code.msdn.microsoft.com/windowsapps/Print-Sample-c544cce6, in scenario three, you would find the setting part for PageMediaSize

    IList<string> displayedOptions = printTask.Options.DisplayedOptions;
    
                                                          // Choose the printer options to be shown.
                                                          // The order in which the options are appended determines the order in which they appear in the UI
                                                          displayedOptions.Clear();
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.MediaSize);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Collation);
                                                          displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Duplex);
    
                                                          // Preset the default value of the printer option
                                                          printTask.Options.MediaSize = PrintMediaSize.NorthAmericaLegal;
    
                                                          // Print Task event handler is invoked when the print job is completed.
                                                          printTask.Completed += async (s, args) =>
                                                          {
                                                              // Notify the user when the print operation fails.
                                                              if (args.Completion == PrintTaskCompletion.Failed)
                                                              {
                                                                  await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                                                  {
                                                                      rootPage.NotifyUser("Failed to print.", NotifyType.ErrorMessage);
                                                                  });
                                                              }
                                                          };
    
                                                          sourceRequestedArgs.SetSource(printDocumentSource);

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, January 10, 2014 7:03 AM
    Moderator