// BinaryPart
BinaryPart binaryPart = new BinaryPart(new PartName("/ppt/media/image" + this.imageId + ".jpeg"));
binaryPart.setBinaryData(image);
binaryPart.setContentType(new org.docx4j.openpackaging.contenttype.ContentType(org.docx4j.openpackaging.contenttype.ContentTypes.IMAGE_JPEG));
binaryPart.setRelationshipType(Namespaces.IMAGE);
Relationship bpRelationship = slidePart.addTargetPart(binaryPart);
Pic pic = new Pic();
// nvPicPr
pic.setNvPicPr(new Pic.NvPicPr());
pic.getNvPicPr().setCNvPr(new CTNonVisualDrawingProps());
pic.getNvPicPr().setCNvPicPr(new CTNonVisualPictureProperties());
pic.getNvPicPr().getCNvPicPr().setPicLocks(new CTPictureLocking());
pic.getNvPicPr().setNvPr(new NvPr());
pic.getNvPicPr().getCNvPr().setId(this.imageId);
pic.getNvPicPr().getCNvPr().setName(name);
pic.getNvPicPr().getCNvPr().setDescr(description);
pic.getNvPicPr().getCNvPicPr().getPicLocks().setNoChangeAspect(true);
pic.setBlipFill(new CTBlipFillProperties());
pic.getBlipFill().setBlip(new CTBlip());
pic.getBlipFill().getBlip().setEmbed(bpRelationship.getId());
pic.getBlipFill().getBlip().setCstate(STBlipCompression.PRINT);
pic.getBlipFill().setStretch(new CTStretchInfoProperties());
pic.getBlipFill().getStretch().setFillRect(new CTRelativeRect());
pic.setSpPr(new CTShapeProperties());
pic.getSpPr().setXfrm(new CTTransform2D());
pic.getSpPr().getXfrm().setOff(new CTPoint2D());
pic.getSpPr().getXfrm().getOff().setX(0);
pic.getSpPr().getXfrm().getOff().setY(0);
pic.getSpPr().getXfrm().setExt(new CTPositiveSize2D());
pic.getSpPr().getXfrm().getExt().setCx(9144000);
pic.getSpPr().getXfrm().getExt().setCy(6858000);
pic.getSpPr().setPrstGeom(new CTPresetGeometry2D());
pic.getSpPr().getPrstGeom().setPrst(STShapeType.RECT);
pic.getSpPr().getPrstGeom().setAvLst(new CTGeomGuideList());
slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(pic);
}
Users browsing this forum: No registered users and 59 guests