简体   繁体   中英

print word document (.docx) from a java application running as windows service

i have written a small java application which is called by an java application running as a windows service. My java application calls the print method in order to print the word document: java.awt.Desktop.getDesktop().print(new File(targetfile));

It works if i call the java application but it does not work if it is executed by the windows service.

What happens is that i have multiple ms word processes running in the background each time the window service tries to execute my java application.

Do you know how i can print from a windows service ?

Thanks,

Asad

If I had to guess... you need to run the Windows Service as a user with appropriate permissions to print.

By default a service will run as System or LocalUser , which will not be able to print. That's why it works when you call it but not the service. Try and set the Log On account for the service to your personal account and see if it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM