Java:如何将剪贴板上的图像粘贴(附加)到Word文档

发布于 2024-08-09 13:31:06 字数 219 浏览 4 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里兽 2024-08-16 13:31:06

还没有测试过,但我会尝试以下步骤:

阅读文档后,尝试从剪贴板读取图像(你可以看看这个网站: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.

ゃ人海孤独症 2024-08-16 13:31:06

我不知道您使用哪个库/代码来解析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 :)

睫毛溺水了 2024-08-16 13:31:06

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文