locked
How can I print a RTF document from a WebService? RRS feed

  • Question

  • I am trying to create a webservice that prints rtf documents.  The following code works well as an application, but fails when I try to use it as a webservice.  Is there a way to fix this to work with a webservice? If there anyway that anyone knows of to print an rtf from a webservice? I'm fine with using impersonation for security if needed.


    Here is what I've been trying:
    private void PrintDocument(string safeFileName)
    {
    Microsoft.Office.Interop.Word._Application app = new Application();
    // Open Doc
    object filename = safeFileName;
    Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing);
    doc.PrintOutOld(ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing);
    app.Quit(ref _missing, ref _missing, ref _missing);
    }
    • Moved by Cindy Meister MVP Friday, October 24, 2008 8:39 AM off-topic (Moved from Visual Studio Tools for Office to Off-Topic Posts (Do Not Post Here))
    Thursday, October 23, 2008 10:12 PM

Answers

All replies

  • My guess it that this is security related. Are you running IIS 6? Is the worker process impersonating? On a different note, you will have performance issues since every request will require a new instance of word to be instantiated. Even if you keep word open on the server side you will have concurrency issues, unless you block every request so that only one executes at time.
    Friday, October 24, 2008 12:12 AM
  • This question is very much off-topic in the VSTO forum. The Please Read First message posted at the top of the forum will tell you what the forum is for and provides links to other venues.
    Cindy Meister, VSTO/Word MVP
    Friday, October 24, 2008 8:39 AM
  •  

    Hello Guxiyu 

    Thank you for your post!  Unfortunately there is not a current forum to post the question you are asking so I would recommend that you post you question to one of the 'microsoft.public.office.developer.vba' located here:  http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.office.developer.vba&mid=1e37e892-d765-44e6-8cfe-5499c029e5ab

    Hope that helps!

    • Proposed as answer by SachinW Friday, October 24, 2008 8:54 AM
    • Marked as answer by SachinW Wednesday, November 12, 2008 12:03 PM
    Friday, October 24, 2008 8:54 AM