-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPPTG.java
More file actions
71 lines (57 loc) · 3.3 KB
/
PPTG.java
File metadata and controls
71 lines (57 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.xslf.usermodel.*;
import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
public class PPTG {
public void createPresentation(Map<String,String> data) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
XMLSlideShow ppt = new XMLSlideShow();
// Create slides for each data element
//data.forEach((key, value) -> createSlideWithText(ppt, value));
String title = AIPrompter.chatGPT("Make a presentation title for this topic: " + data.get("topic"));
String header = AIPrompter.chatGPT("Make a presentation title for this topic: " + data.get("audience"));
String down = AIPrompter.chatGPT("Make a presentation title for this topic: " + data.get("slides"));
String up = AIPrompter.chatGPT("Make a presentation title for this topic: " + data.get("author"));
String left = AIPrompter.chatGPT("Make a presentation title for this topic: " + data.get("date"));
String titlebullets = AIPrompter.chatGPT("Make 2 bullet points for this topic: " + data.get("topic"));
String headerbullets = AIPrompter.chatGPT("Make 2 bullet points for this topic: " + data.get("audience"));
String downbullets = AIPrompter.chatGPT("Make 2 bullet points for this topic: " + data.get("slides"));
String upbullets = AIPrompter.chatGPT("Make 2 bullet points for this topic: " + data.get("author"));
String leftbullets = AIPrompter.chatGPT("Make 2 bullet points for this topic: " + data.get("date"));
createSlideWithText(ppt, title, titlebullets);
createSlideWithText(ppt, header, headerbullets);
createSlideWithText(ppt, down, downbullets);
createSlideWithText(ppt, up, upbullets);
createSlideWithText(ppt, left, leftbullets);
createSlideWithPicture( ppt, "C:\\Users\\Acer Customer\\Downloads\\Computer.jpeg");
try (FileOutputStream out = new FileOutputStream("presentation.pptx")) {
ppt.write(out);
}
}
private void createSlideWithPicture(XMLSlideShow ppt, String picture) throws IOException {
XSLFSlide slide = ppt.createSlide();
XSLFPictureData pd = ppt.addPicture(new File(picture), PictureData.PictureType.JPEG);
XSLFPictureShape pic = slide.createPicture(pd);
pic.setAnchor(new Rectangle(150, 250, 400, 500));
}
private void createSlideWithText(XMLSlideShow ppt, String text, String bullets) {
XSLFSlide slide = ppt.createSlide();
XSLFTextBox textBox1 = slide.createTextBox();
XSLFTextBox textBox2 = slide.createTextBox();
textBox1.setText(text);
textBox2.setText(bullets);
textBox1.setAnchor(new Rectangle(50, 50, 400, 50));
textBox2.setAnchor(new Rectangle(50, 125, 400, 50));
}
//private void createSlideWithText(XMLSlideShow ppt, String text) {
// XSLFSlide slide = ppt.createSlide();
// XSLFTextBox textBox = slide.createTextBox();
// textBox.setText(text);
// textBox.setAnchor(new Rectangle(50, 50, 400, 50));
//textBox.setAnchor(new Rectangle(50, 80, 400, 50));
//}
}