How to Read images from word(DOC) file and add it to pdf file?

天大地大妈咪最大 提交于 2019-12-14 03:35:27

问题


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

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.

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

If anyone have this code please help me out.

Thank you so much for your time..


回答1:


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


来源:https://stackoverflow.com/questions/18740361/how-to-read-images-from-worddoc-file-and-add-it-to-pdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!