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

查看:32
本文介绍了如何从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();

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

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