0

I have programmed a Windows Service that open a document in Microsoft Word, and then print it to a Ghostscript PDF printer to create a PDF file.

It works perfectly on Windows 2003 server. But running it on Windows 2008 r2 fails. I am aware of the Desktop folders that need to be created under the system profile, and that solved another problem I had at first.

If I run the service as an application instead, everything works perfect. So it seems that everything is setup and configured correctly.

But when I run it as a Service, I get the following error in my logfile, generated from Microsoft Word:

Error in Microsoft Word: Word cannot print. There is no printer installed.

I have added a printer and manually selected the Ghostscript driver, and also set it as a default printer. So it should work.

When I added the printer I was logged in as an administrator. And it is the same user that runs the Service (it is not the system user). However I have read somewhere that the services still uses the internal users environment in 2008, so maybe that is the problem.

migrated from stackoverflow.com Jan 15 '13 at 8:42

This question came from our site for professional and enthusiast programmers.

  • 2
    Everyone posting questions here is seeking answers as quickly as possible. – Damien_The_Unbeliever Jan 15 '13 at 7:47
0

You wont believe this. I finally got it to work.

Everytime I ran my Service the printer job got stuck in the queue with status "spooling...". I discovered that the following code segment somehow upheld the printing job.

while (WordApp.BackgroundPrintingStatus > 0) { sleeeeeeeeep for 250 milliseconds }

Removing this solved the problem!! The printerjob never get stuck, and runs smothly.

Unbelievable..

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy