如何从word(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 ).

如果有人有这个代码,请帮帮我.

If anyone have this code please help me out.

非常感谢您的时间..

您可以使用此代码从文档中获取所有图像.

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();