简体   繁体   English

使用 JACOB 将 Word 文档拆分为页面

[英]Splitting word document to pages using JACOB

I have been trying to split a word document to pages.我一直在尝试将 Word 文档拆分为页面。 A through POC that led to the fact that this cannot be done through Apache POI, and consequently made me resort to JACOB to invoke MS Word as a proxy to achieve such transformation.一个通过 POC 导致这不能通过 Apache POI 完成的事实,因此使我求助于 JACOB 调用 MS Word 作为代理来实现这种转换。

I have made some reasonable advancements with my code, now I am able to open a document, search, replace, and so on.我对我的代码进行了一些合理的改进,现在我可以打开文档、搜索、替换等。 However I am unable to get the "page" bookmark但是我无法获得“页面”书签

            ActiveXComponent oDocuments = oWord.getPropertyAsComponent("Documents");
        ActiveXComponent oDocument = oDocuments.invokeGetComponent("Open", new Variant(sInputDoc), new Variant(false));
        ActiveXComponent oSelection = oWord.getPropertyAsComponent("Selection");

        ActiveXComponent oBookmarks = oSelection.getPropertyAsComponent("Bookmarks");
        int bookMarksnumber = oBookmarks.getProperty("Count").getInt();
        System.out.println(bookMarksnumber);

This always returns 0 (If the same can be achieved using POI I am open to all suggestions)这总是返回 0(如果使用 POI 可以实现相同的结果,我愿意接受所有建议)

用它来实现书签

ActiveXComponent oBookmarks = oDocument.getPropertyAsComponent("Bookmarks");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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