Search code examples
javams-wordfreedocx

Printing docx by Java


How to pass / send a pre-designed .docx file to a printer to be printed , without open MS Word, by Java using either native libraries or other free 3rd party libraries.


Solution

  • There's a few options:

    • Use LibreOffice to open the document and print it. This should provide reasonably good results without the need for a MS Word License / Windows.
    • Use Apache POI to open the document, extract the information you want and print it yourself using the Java Print API. Unless you're processing known documents this will be exceedingly difficult.
    • Use Microsoft Word through COM (this may meet your requirement, since no Word window needs to actually open, it'll run in the background), open the document and print it. This will require use of the Java COM Bridge which has some nasty native requirements and would require Windows.