如何从字(DOC)文件中读取图像,并将其添加到pdf文件? [英] How to Read images from word(DOC) file and add it to pdf file?

查看:207
本文介绍了如何从字(DOC)文件中读取图像,并将其添加到pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含文本,图像的doc文件等等等等。

I have a doc file that contains text,images etc etc.

现在我想读的doc文件和这些内容写入PDF文件。我的DOC文件和新生成的PDF文件必须相同。

Now I want to read that doc file and write those contents into pdf file. My DOC file and newly generated PDF file has to be same.

我再说一遍,我的DOC文件包含(图像以及文本的数据)。

I repeat, My DOC file contains ( "images as well as text" data ).

如果任何人有这个code,请帮助我。

If anyone have this code please help me out.

感谢您这么多的时间。

推荐答案

您可以使用此code,从文档中获取的所有图像。

You can use this code to get all the images from your document.

HWPFDocument doc = new HWPFDocument(fs);// fs is the object of POIFSFileSystem 
Range range = doc.getRange();
PicturesTable pt = doc.getPicturesTable();
List<Picture> listPic = pt.getAllPictures();
Picture pic = listPic.get(0);// iterate listPic upto its size to get images
byte[] picArr = pic.getContent();

这篇关于如何从字(DOC)文件中读取图像,并将其添加到pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆