Java:如何将剪贴板上的图像粘贴(附加)到Word文档
Java中有没有办法将剪贴板的内容(在我的例子中是图像)复制到word文档的末尾?
我想要一个程序能够- * 以文件名(word文件)作为参数 * 每当运行此程序时 - 它将打开 Word 文件并将剪贴板的内容粘贴到文档的末尾。
我已经完成了第一部分 - 但正在努力完成第二部分。也尝试过 POI 但无法使其工作。
非常感谢任何帮助或指示。
问候, - 阿什什
Is there a way in Java, to copy the contents of the clipboard (an image in my case) to the end of a word document?
I want to have a program that will -
* Take a filename (word file) as a parameter
* Whenever this program is run - it will open the word file and paste the contents of the clipboard to the end of the document.
I am done with the first part - but am struggling with the second part. Also tried POI but could not get it to work.
Any help or pointers are greatly appreciated.
Regards,
- Ashish
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
还没有测试过,但我会尝试以下步骤:
阅读文档后,尝试从剪贴板读取图像(你可以看看这个网站:ToClipImg.html) 并临时 (File.createTempFile(...)) 将图像保存到磁盘。
先保存图像然后将其添加到 POI 可能会更容易。
Haven't tested it, but I would try these steps:
After reading the document, try to read the image from the clipboard (you can have a look at this website: ToClipImg.html) and temporarily (File.createTempFile(...)) save the image to disk.
It might be easier to save the image first and then add it with POI.
我不知道您使用哪个库/代码来解析Word文件,但是Aspose.Words在解析Word文件方面做得非常好。然而它不是免费的,但它使用起来相当简单,有足够好的文档和一个非常可靠的基于论坛的帮助台。
查看他们的网站。不,我不是 Aspose 员工,它只是一个很好的软件:)
I don't know which library/code you're using for parsing the Word file, but Aspose.Words does a pretty good job parsing Word files. It's not free however, but it is rather straightforward to use, has decent enough documentation and a pretty solid forum-based helpdesk.
Check out their website. And no, I'm not an Aspose employee, it's just a good piece of software :)
http://poi.apache.org/hwpf/index.html
它位于早期开发,但你可以在 SVN 目录中查看它
http://poi.apache.org/hwpf/index.html
It is in early development but you can check it out in the SVN dir