FileInputStream fis = new FileInputStream(docRealPath); HWPFDocument doc = new HWPFDocument(fis); Picture pic = doc.getPicturesTable().getAllPictures().get(0); pic.getWidth(); //gives -1 pic.getHeight(); //gives -1 pic.getVerticalScalingFactor() //NullPointerException at org.apache.poi.hwpf.usermodel.Picture.getVerticalScalingFactor(Picture.java:491) pic.getHorizontalScalingFactor() //NullPointerException at org.apache.poi.hwpf.usermodel.Picture.getHorizontalScalingFactor(Picture.java:429) pic.getDxaGoal() //NullPointerException at org.apache.poi.hwpf.usermodel.Picture.getDxaGoal(Picture.java:378) pic.getDyaGoal() //NullPointerException at org.apache.poi.hwpf.usermodel.Picture.getDyaGoal(Picture.java:407) So I can't determine the size of the picture in the Word document. It is an MSWord 97/2000/XP format.
It is an MSWord document with one picture inserted from file (.jpg).
It's a long time since your bug-report, but can you attach a sample-file which allows to reproduce this? Otherwise it is impossible to fix anything here...
thank you, but meanwhile I solved it with poi-3.14-beta1, pic.getHorizontalScalingFactor(), pic.getVerticalScalingFactor(), pic.getDxaGoal(), pic.getDyaGoal() or: PICFAndOfficeArtData data = new PICFAndOfficeArtData(pic.getRawContent(), 0); dxaGoal = data.getPicf().getDxaGoal(); dyaGoal = data.getPicf().getDyaGoal(); aspectRatioX = data.getPicf().getMx(); aspectRatioY = data.getPicf().getMy();
Ok, thanks for the note, so I close this as having a workaround/solution.