PrintOut() and default printers - InfoPath Dev
in

InfoPath Dev

PrintOut() and default printers

Last post 04-11-2005 11:20 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-23-2005 09:28 AM

    PrintOut() and default printers

    Hi All,

    Here is an interesting PrintOut() scenario.

    As expected, calling PrintOut() with no printerName set in the view printSettings results with the InfoPath form being printed out to the user's default printer.

    To simplify the scenario. The same form has two views;
    one view to print the whole form on A4 paper.
    a second view to print parts of the form on bottle labels.

    The slight complication is depending on the current user, the A4 and bottle label printers are different i.e. different departments.

    A secondary data source provides the correct printer names - 1 for A4, 1 for bottle labels.

    When either the A4 or label print button is pressed, WMI code is used to change the users default printer to the appropriate A4 or label printer.
    This works with no problems and can be seen successfully changing the default printer in the Printer and Faxed control panel.

    Now this is the problem! Whatever the user prints first e.g. labels, all subsequent print outs will be sent to the label printer despite the WMI code successfully changing the users default printer before the PrintOut() call.

    To re iterate, should the user close the form and print A4 first. All subsequent PrintOut() calls will be sent to the A4 printer.

    To really simplify this example. A test harness has been created which has a button control. The button control calls thisXDocument.PrintOut() in managed code. The first time this button is pressed the users current default printer is used to print out the form. Next i manually change the default printer in the Printer and Faxes control panel. The print button is pressed again and the form is printed out to the first / original default printer.

    Furthermore analysis of thisXDocument.Solution.DOM.xml results with identical data. i.e. nothing changes between print outs.

    Can someone shed any light onto why InfoPath appears to be storing the printer used in the first PrintOut() call and subsequently using this printer irrespective of any default printer changes???

    Your help and time is really appreciated.
    Kind regards
    Scott
  • 03-29-2005 03:56 PM In reply to

    Re: PrintOut() and default printers

    This sounds like it could be a timing issue. That perhaps the printer change is not actually happening until after the first printout occurs.

    Greg Collins [InfoPath MVP]
    InfoPathDev
  • 03-30-2005 12:27 AM In reply to

    Re: PrintOut() and default printers

    Hi Greg,
    thanks for your reply. I did think this was a timing issue at the beginning but i believe there must be something somewhere being recorded because to really simplify my example;

    A test harness has been created which has a button control. The button control calls thisXDocument.PrintOut() in managed code. The first time this button is pressed the users current default printer is used to print out the form. After the print out has completed, i manually change the default printer in the Printer and Faxes control panel. The print button is pressed again and the form is printed out to the first / original default printer.

    What is more frustrating is analysis of thisXDocument.Solution.DOM.xml (the manifest i believe) results with identical data. i.e. nothing changes between print outs but surely something has to otherwise surely InfoPath would use the default printer.

    Any ideas?
    Kind regards
    Scott
  • 04-11-2005 11:20 AM In reply to

    Re: PrintOut() and default printers

    Perhaps InfoPath is caching the default printer choice when the application loads? Not sure what is going on.

    Greg Collins [InfoPath MVP]
    InfoPathDev
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.