Skip to content

Instantly share code, notes, and snippets.

@kenmlee
Created June 13, 2019 06:15
Show Gist options
  • Save kenmlee/4f78af05bad884f058742d50add6bf4d to your computer and use it in GitHub Desktop.
Save kenmlee/4f78af05bad884f058742d50add6bf4d to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws Exception
{
String dataPath = "src/featurescomparison/workingwithimages/extractimagesfromdocument/data/";
HWPFDocument doc = new HWPFDocument(new FileInputStream(
dataPath + "document.doc"));
List<Picture> pics = doc.getPicturesTable().getAllPictures();
for (int i = 0; i < pics.size(); i++)
{
Picture pic = (Picture) pics.get(i);
FileOutputStream outputStream = new FileOutputStream(
dataPath + "Apache_"
+ pic.suggestFullFileName());
outputStream.write(pic.getContent());
outputStream.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment