How to set up Printer by JACOB to print word document?

Fonlin 0 Reputation points


We need to specify a printer to print word doc by java(jacob), and this may happen in a multithreaded environment.


At the beginning we use this method but concurrency problems occurred. When two threads execute this code at the same time, the printer of the two print tasks will be mixed.

word.setProperty("ActivePrinter", new Variant(printerName));

So we found another way to achieve it with FilePrintSetup, in this article.

Dispatch wordBasic =, "WordBasic").toDispatch();, "FilePrintSetup", new Variant(printerName), new Variant(false));

But when we actually use it, the second parameter can only pass false, because when true is passed, there will be a UI dailog of the printer to block the continued execution of the program, as shown in the figure below.

User's image

When pass false, the same concurrency problems still occur. Is there any good solution? Thank you

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
2,854 questions
0 comments No comments
{count} votes