locked
How to determine the default PaperSize for the current locale from inside the V4 print driver JavaScript constraint script?

    Question

  • Hello,

    As I know, there is a possibility in the system to automatically choose the default value for PaperSize feature for Unidrv-based printer driver depending on the current locale (for details, see the description of the *DefaultOption attribute here).

    In our V4 print driver we have the JavaScript constraint script with the validatePrintTicket function which should reset the PaperSize feature to the default value in case PaperSize is constrained with some other feature.

    We would like to make the validatePrintTicket function reset PaperSize to the default value depending on the current locale (i.e. to A4 for metric locales and to Letter otherwise).

    Is there any way to do this?

    Thank you.

    Monday, August 6, 2012 12:23 PM

Answers

  • Dmitry,

    We don't make the current locale available to constraint JavaScript. You should be able to work around this using the user property bag in your printer extension or Metro style device app, though. When the user opens your printer extension or Metro style device app, just store the user's default paper size as a property in the user property bag, and then read that back in the JavaScript constraints.

    Thanks!

    Justin

    Monday, August 6, 2012 6:20 PM

All replies

  • Dmitry,

    We don't make the current locale available to constraint JavaScript. You should be able to work around this using the user property bag in your printer extension or Metro style device app, though. When the user opens your printer extension or Metro style device app, just store the user's default paper size as a property in the user property bag, and then read that back in the JavaScript constraints.

    Thanks!

    Justin

    Monday, August 6, 2012 6:20 PM
  • Hi Justin,

    Thank you for the answer!

    I guess your workaround would not work in case of printer sharing (because there might be no printer extensions installed), would it?

    I also came up with some different idea: what if we had some special non-visible feature in GPD (with ConcealFromUI attribute) for which we would have special localization in the resource DLL - we would make its localization hold the default paper size name for the given language. Then we could determine the default paper size by looking at DisplayName property for that feature inside Print Capabilities. However, to have this information in validatePrintTicket we would have to get the PrintCapabilities document inside validatePrintTicket function (through the call to IPrintSchemaTicket.GetCapabilities), which would cause some performance degradation according to my previous observations. So this is also not an ideal solution.

    What do you think?

    Wednesday, August 8, 2012 9:39 AM
  • Dmitry,

    I agree. It sounds like there isn't going to be a 100% workaround for this. This wasn't a scenario we designed for, but I do understand it now. Good luck!

    Justin

    Wednesday, August 8, 2012 4:57 PM