Handling IPrintOemPrintTicketProvider::ValidatePrintTicket

If you're writing a plug-in driver for Unidrv or PScript, there's a design quirk that you should be aware of, and should code around it accordingly.

UnidrvUI.DLL and PS5UI.dll implement IPrintTicketProvider.  That interface has a ValidatePrintTicket call.  In that call, the logic is a bit complicated, but the basic flow works like this:

  1. Convert PrintTicket to DEVMODE (including plug-in calls to convert)
  2. Valdiate option defined in GPD / PPD
  3. Erase GPD / PPD features listed in PrintTicket
  4. Convert DEVMODE back to PrintTicket (including plug-in calls to convert)
  5. Call plug-in ValidatePrintTicket

The issue arises in that in step 3, there's no equivalent plug-in call.  What this effectively means is that if the plug-in adds new features not described in the GPD / PPD during conversion from DEVMODE to PrintTicket, those features appear as duplicates in the PrintTicket.  To fix this, in the conversion from DEVMODE to PrintTcket, the plug-in should verify that the features don't already exist before writing content into the PrintTicket.  If the features do exist, the plug-in can either update them in-place, or remove the features and re-write the new values.  The output from ValidatePrintTicket does not go through the run-time validation for performance reasons, but that means when the app passes the validated PrintTicket back into the printing system, at that time the duplicate feature will be detected and result in a failure.