问题
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