Hi Savotii, I've made some changes to the codebase [1] - the placeholder code in XSLFShape.getPlaceholder() based on the placeholder type instead of the index is not valid for all cases ...
Please use a nightly [2] tomorrow, when the changes are compiled into.
You can then use the following code:
public class TestLayoutImages {
static List<Function<XDDFTextBody,XDDFParagraphProperties>> PARA_PROPS =
Arrays.asList(
XDDFTextBody::getDefaultProperties, XDDFTextBody::getLevel1Properties,
XDDFTextBody::getLevel2Properties, XDDFTextBody::getLevel3Properties,
XDDFTextBody::getLevel4Properties, XDDFTextBody::getLevel5Properties,
XDDFTextBody::getLevel6Properties, XDDFTextBody::getLevel7Properties,
XDDFTextBody::getLevel8Properties, XDDFTextBody::getLevel9Properties
); @Test public void exportImages() throws IOException {
try (FileInputStream fis = new FileInputStream("example.pptx");
XMLSlideShow ppt = new XMLSlideShow(fis)) {
XSLFSlide slide = ppt.getSlides().get(0); XSLFTextShape list =
(XSLFTextShape)slide.getShapes().get(0); XSLFAutoShape shape =
(XSLFAutoShape)list.getPlaceholderDetails().getPlaceholderShape(); XDDFTextBody
phBody = shape.getTextBody(); int indent =
list.getTextParagraphs().get(0).getIndentLevel(); XDDFParagraphProperties props
= PARA_PROPS.get(indent == 0 || indent > 9 ? 1 : indent).apply(phBody); String
bulletId =
props.getBulletProperties().getXmlObject().getBuBlip().getBlip().getEmbed();
POIXMLDocumentPart rel = slide.getMasterSheet().getRelationById(bulletId);
PackagePart pp = rel.getPackagePart(); try (InputStream is =
pp.getInputStream(); FileOutputStream fos = new FileOutputStream(new
File(pp.getPartName().getName()).getName())) {
IOUtils.copy(is, fos); }
}
}
}
Best wishes,
Andi
[1] https://svn.apache.org/viewvc?view=revision&revision=1875328
[2]
https://builds.apache.org/view/P/view/POI/job/POI-DSL-1.8/lastSuccessfulBuild/artifact/build/dist/
signature.asc
Description: OpenPGP digital signature
