Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask for help, print .docx file to physical printer by jacob (JAVA-COM Bridge) as Monochrome printing #51

Open
yeminv opened this issue Dec 21, 2023 · 1 comment

Comments

@yeminv
Copy link

yeminv commented Dec 21, 2023

I want to print .docx file to a physical printer by jacob. And it's work as below.

       <dependency>
            <groupId>com.jacob</groupId>
            <artifactId>jacob</artifactId>
            <version>1.20</version>
        </dependency>
public class JacobPrint {
    static void print( String filePath){// filePath="D:\\1.doc";
        ComThread.InitSTA();
        ActiveXComponent word=new ActiveXComponent("Word.Application");
        Dispatch doc=null;
        Dispatch.put(word, "Visible", new Variant(false));
        Dispatch docs=word.getProperty("Documents").toDispatch();
        doc=Dispatch.call(docs, "Open", filePath).toDispatch();

        try {
            Dispatch.call(doc, "PrintOut");
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            try {
                if(doc!=null){
                    Dispatch.call(doc, "Close",new Variant(0));
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            ComThread.Release();
        }
}

But it is color printing. How do I control it to print in color or monochrome?

I have reference to Microsoft's official documentation: Printer.ColorMode property (Access)

But it seems to only work in the Access app, not in Word.

Thanks a lot!

@EJP286CRSKW
Copy link

This isn't a Jacob issue. Jacob will execute whatever calls you need to make. It's a question about the Microsoft COM API for Word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants