Bulk print of browser-enabled forms from SharePoint page - InfoPath Dev
in

InfoPath Dev

Bulk print of browser-enabled forms from SharePoint page

Last post 09-23-2009 01:51 AM by philljenkins. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-22-2009 08:35 AM

    Bulk print of browser-enabled forms from SharePoint page

    I have Sharepoint 2007 with a list of browser-enabled infopath forms. I have an aspx page which enables the user to select a date range. When the user clicks a 'Print' button on the page the code behind can process the list of forms, and find all forms for which the form date (a field in the form) lies within the selected date range. Now I want the code to print the found forms. And that's where I come unstuck. I tried code like the following (where urlClaim is a url to the form .xml)

        Microsoft.Office.Interop.InfoPath.Application ipApp = null;
       try
       {
        ipApp = new Microsoft.Office.Interop.InfoPath.Application();
        XDocument myXDoc = ipApp.XDocuments.Open(urlClaim,(int)XdDocumentVersionMode.xdFailOnVersionOlder);
        myXDoc.PrintOut();
       }
       catch (Exception ex)
       {
        AddMessage("Print failed with " + ex.Message);
       }

     Unfortunately the call on Open never returns. But after some thinking I realise that perhaps the InfoPath app can't open the browser enabled form.

     So, assuming that using the InfoPath app is the wrong answer, how do I print a browser-enabled form from code?

     

  • 09-23-2009 01:03 AM In reply to

    Re: Bulk print of browser-enabled forms from SharePoint page

    infopath app can open broswer enabled forms. so there must be some other thing that is going wrong. just debug your code and see what is going wrong

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 09-23-2009 01:51 AM In reply to

    Re: Bulk print of browser-enabled forms from SharePoint page

    Thanks Qazi.

    I have debugged my code, again and again. I can't find anything wrong.

    My code is


      private void PrintClaim(string urlClaim)
      {
       Microsoft.Office.Interop.InfoPath.Application ipApp = null;
       try
       {
        ipApp = new Microsoft.Office.Interop.InfoPath.Application();
        AddMessage("Created InfoPath app object");
        XDocument xdocClaim = ipApp.XDocuments.Open(urlClaim, (int)XdDocumentVersionMode.xdCanOpenInReadOnlyMode );
        AddMessage("Opened claim");
        xdocClaim.PrintOut();
        AddMessage("Printed claim");
       }
       catch (Exception ex)
       {
        AddMessage("Print failed with " + ex.Message);
       }
       finally
       {
        ipApp.Quit(true);
       }
      }

    I know from the trace provided by AddMessage that it gets up to the ipApp.XDocuments.Open statement but that that never returns.

    I have tried different VersionMode values to no avail. Looking at Task Manager I can see the INFOPATH.EXE process that is created. If I kill that the code proceeds to catch an exception. There are no clues in the host events nor in the SharePoint logs.

    The url I am passing in is of the form http://site/library/form.xml (e.g. http://portal.dev.envirolink.local/admin/tec/Claims/TS-pjenkins-20090907.xml)

    If the url 'bad'? Have I created ipApp badly? Is there some other property of ipApp I should be setting? Should I be passing different arguments to Open?

    Thanks for your help.

    Phill

     

     

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.