Bug 59434 - Cannot add a picture on a slide that already have an image with an hyperlink on it
Summary: Cannot add a picture on a slide that already have an image with an hyperlink ...
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.15-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2016-05-06 16:19 UTC by Aurélien
Modified: 2016-05-12 15:51 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Aurélien 2016-05-06 16:19:51 UTC
If a slide has a picture, it is possible to add a new picture on the slide using the code :
byte[] pictureData = IOUtils.toByteArray(new FileInputStream("image.png"));
XSLFPictureData pd = ppt.addPicture(pictureData, PictureData.PictureType.PNG);
XSLFPictureShape pic = slide.createPicture(pd);

However, if the picture already present on the slide have an hyperlink on it, the new picture cannot be added to the slide.
Here is the stack trace generated:
Exception in thread "main" org.apache.poi.POIXMLException: invalid package relationships
	at org.apache.poi.POIXMLDocumentPart.findExistingRelation(POIXMLDocumentPart.java:368)
	at org.apache.poi.POIXMLDocumentPart.addRelation(POIXMLDocumentPart.java:330)
	at org.apache.poi.xslf.usermodel.XSLFSheet.createPicture(XSLFSheet.java:226)
	at PoiTest.main(PoiTest.java:25)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Absolute URI forbidden: http://google.fr/test_poi
	at org.apache.poi.openxml4j.opc.PackagePartName.throwExceptionIfAbsoluteUri(PackagePartName.java:428)
	at org.apache.poi.openxml4j.opc.PackagePartName.throwExceptionIfInvalidPartUri(PackagePartName.java:177)
	at org.apache.poi.openxml4j.opc.PackagePartName.<init>(PackagePartName.java:85)
	at org.apache.poi.openxml4j.opc.PackagingURIHelper.createPartName(PackagingURIHelper.java:493)
	at org.apache.poi.openxml4j.opc.PackagePart.getRelatedPart(PackagePart.java:485)
	at org.apache.poi.POIXMLDocumentPart.findExistingRelation(POIXMLDocumentPart.java:362)
	... 3 more
Comment 1 Andreas Beeker 2016-05-08 13:29:45 UTC
Thanks for bringing this up.
Fixed with r1742816
Comment 2 Aurélien 2016-05-12 15:51:18 UTC
Thank you for this fix!