使用 com4j 打印 MSWord 文档
我正在尝试使用 com4j 打印出 .doc 文件。 这是我的代码:
document.printOut2000(true, false, WdPrintOutRange.wdPrintAllDocument, newDocumentPath, _, _, WdPrintOutItem.wdPrintDocumentContent, 1, _, WdPrintOutPages.wdPrintAllPages, true, true, _, false, 0, 0, 0, 0);
我从记录的 Word-Macro 和 http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.printout(v=VS.80)。 aspx
但我得到的只是以下错误:
Java 运行时环境检测到意外错误:
EXCEPTION_ACCESS_VIOLATION (0xc0000005),位于 pc=0x770f48f9、pid=3792、tid=5996
Java VM:Java HotSpot(TM) 客户端 VM(11.0-b16 混合模式,共享 windows-x86) 有问题的框架: C [OLEAUT32.dll+0x48f9]
知道如何解决这个问题吗?
编辑:Com4j 正在打开文档,所以我认为以前方法的结果不是问题,但感谢 DTH 的提示。
I'm trying to print out a .doc-File with com4j.
This is my Code:
document.printOut2000(true, false, WdPrintOutRange.wdPrintAllDocument, newDocumentPath, _, _, WdPrintOutItem.wdPrintDocumentContent, 1, _, WdPrintOutPages.wdPrintAllPages, true, true, _, false, 0, 0, 0, 0);
I got the values from a recorded Word-Macro and http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.printout(v=VS.80).aspx
But all i get is the following error:
An unexpected error has been detected by Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x770f48f9, pid=3792, tid=5996
Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode, sharing windows-x86)
Problematic frame:
C [OLEAUT32.dll+0x48f9]
Any idea how i can solve this?
Edit: Com4j is opening the document, so I think the results of the previous methods aren't the problem, but thanks to DTH for the hint.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
访问冲突通常与内存问题有关,例如缓冲区覆盖甚至空指针。
我建议您再次检查代码,并在打印前控制用于准备文档的方法的结果,以便您可以查看它们是否正常工作。
我对此不太确定,但尝试一下,也许这就是您问题的解决方案。
Access Violation has often to do with a memory problem, for example buffer overwrite or even a null pointer.
I would suggest you to check your code again and control the results of the methods you are using to prepare the document before printing, so you can see if they are working correct.
I'm not really sure about that, but try it, maybe it's the solution to your problem.