package com.unibail.ppt;

import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Paths;

import org.apache.poi.util.IOUtils;

import com.coreoz.ppt.PptImageReplacementMode;
import com.coreoz.ppt.PptMapper;

public class PptTemplateDemo {

	public static void main(String[] args) throws IOException {
		try(FileOutputStream out = new FileOutputStream("generated.pptx")) {
			new PptMapper()
				.hide("hidden", arg -> "true".equals(arg))
				.text("var1", "Content replaced")
				.text("var3", "Header cell replaced")
				.text("var4", "Content cell replaced")
				.image("image1", IOUtils.toByteArray(PptTemplateDemo.class.getResourceAsStream("/images/replacedImage.jpg")))
				.image(
					"image2",
					IOUtils.toByteArray(PptTemplateDemo.class.getResourceAsStream("/images/replacedImage.jpg")),
					PptImageReplacementMode.RESIZE_ONLY
				)
				.styleText("style", textRun -> {
					textRun.setBold(true);
					textRun.setFontColor(Color.GREEN);
				})
				.processTemplate(PptTemplateDemo.class.getResourceAsStream("/template.pptx"))
				.write(out);
		}
		System.out.println("Templated presentation generated in " + Paths.get("generated.pptx").toAbsolutePath());
	}

}

@@ -42,16 +42,50 @@
 .Color;%0A
+import java.awt.geom.Rectangle2D;%0A
 import j
@@ -1035,16 +1035,318 @@
 %0A%09%09%09%09%7D)%0A
+%09%09%09%09.styleShape(%22percentage%22, shape -%3E %7B%0A%09%09%09%09%09Rectangle2D shapeAnchor = shape.getAnchor();%0A%09%09%09%09%09shape.setAnchor(new Rectangle2D.Double(%0A%09%09%09%09%09%09shapeAnchor.getX(),%0A%09%09%09%09%09%09shapeAnchor.getY(),%0A%09%09%09%09%09%09// widen the shape of 20%25%0A%09%09%09%09%09%09shapeAnchor.getWidth() * 1.2,%0A%09%09%09%09%09%09shapeAnchor.getHeight()%0A%09%09%09%09%09));%0A%09%09%09%09%7D)%0A
 %09%09%09%09.pro

Add an example with shape styling