Home > .Net, Miscellaneous, Office Interoperability > Printing Infopath forms

Printing Infopath forms

While working in Infopath forms, there may some situations where you may need to Print the InfoPath form. But the problem of Infopath API is that we can’t specify the printer name for printing. Like this one

InfoApp.XDocuments(0).PrintOut()

The printout method doesn’t have any parameters like Printer name or port etc. As a workaround you can export the Infopath document as Word, and print the document using Word API, where you can specify the printer name. To export the Infopath as Word there is no direct method, but you can do export to “MHT”(MHTML Document), and change the extention to “.doc” and using Word.Application you can open it and Print.

'Creating the Infopath application
Dim InfoApp As New InfoPath.Application()
'Opening the Infopath document.
InfoApp.XDocuments.Open("C:\Sample\template.xml")
'Exporting the document as Word(MHT)
InfoApp.XDocuments(0).View.Export("C:\Sample\Samplex.doc", "MHT")

Let me know if you find any other solutions :)

  1. Lolopo
    February 4th, 2009 at 16:45 | #1

    I found a solution that helps you printing infopath forms directly from your sharepoint library. Go to http://www.sharepointprinting.com and let me know if this is what you need.

  2. February 4th, 2009 at 17:00 | #2

    Thanks Lolopo. Thanks for sharing the information.

  3. Suresh
    April 21st, 2009 at 13:34 | #3

    hi

    I am using Info Path 2007 and displayed page on Web site.My requirement is to provide the print button option to print the page.For me there is no PrintOut()methods.Please help me

  4. April 22nd, 2009 at 08:43 | #4

    Suresh, sorry I don’t have any experience in Web pages using Infopath. I used info path with windows forms only. And my version was Office 2003.

  1. No trackbacks yet.