}; Slide<?,?> slide = ppt.createSlide();
import java.awt.geom.Rectangle2D; import java.io.FileOutputStream; import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.usermodel.*; public class HslfTextBox { public static void main(String[] args) throws Exception { SlideShow ppt = new SlideShow(); Slide s = ppt.createSlide(); TextBox txt = new TextBox(); txt.setAnchor(new Rectangle2D.Double(100,100,100,100)); TextRun run = txt.createTextRun(); RichTextRun rtr1 = run.getRichTextRuns()[0]; rtr1.setText("small text\n"); rtr1.setFontSize(10); RichTextRun rtr2 = run.appendText("big text\n"); rtr2.setBold(true); rtr2.setFontSize(14); s.addShape(txt); FileOutputStream fos = new FileOutputStream("hssftext.ppt"); ppt.write(fos); fos.close(); } }
Slide slide = slideShow.createSlide();
public static void slide8(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.TITLE); box1.setText("Wait, there is more!"); box1.setAnchor(new Rectangle(36, 21, 648, 90)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.BODY); box2.setText( "Rich text\r" + "Tables\r" + "Pictures (JPEG, PNG, BMP, WMF, PICT)\r" + "Comprehensive formatting features"); box2.setAnchor(new Rectangle(36, 126, 648, 356)); }
public static void slide2(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.TITLE); box1.setText("What is HSLF?"); box1.setAnchor(new Rectangle(36, 21, 648, 90)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.BODY); box2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " + "of the Powerpoint binary file format. \r" + "POI sub-project since 2005\r" + "Started by Nick Burch, Yegor Kozlov joined soon after"); box2.setAnchor(new Rectangle(36, 126, 648, 356)); }
public static void slide5(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.TITLE); box1.setText("HSLF in Action - 1\rData Extraction"); box1.setAnchor(new Rectangle(36, 21, 648, 100)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.BODY); box2.setText( "Text from slides and notes\r" + "Images\r" + "Shapes and their properties (type, position in the slide, color, font, etc.)"); box2.setAnchor(new Rectangle(36, 150, 648, 300)); }
public static void slide12(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.CENTER_TITLE); box1.setText("Questions?"); box1.setAnchor(new Rectangle(54, 167, 612, 115)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY); box2.setText( "http://poi.apache.org/hslf/\r" + "http://people.apache.org/~yegor"); box2.setAnchor(new Rectangle(108, 306, 504, 138)); } }
public static void slide3(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.TITLE); box1.setText("HSLF in a Nutshell"); box1.setAnchor(new Rectangle(36, 15, 648, 65)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.BODY); box2.setText( "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" + "Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" + "Comprehensive support of PowerPoint objects\r" + "Rich text\r" + "Tables\r" + "Shapes\r" + "Pictures\r" + "Master slides\r" + "Access to low level data structures" ); List<? extends TextParagraph<?,?,?>> tp = box2.getTextParagraphs(); for (int i : new byte[]{0,1,2,8}) { tp.get(i).getTextRuns().get(0).setFontSize(28d); } for (int i : new byte[]{3,4,5,6,7}) { tp.get(i).getTextRuns().get(0).setFontSize(24d); tp.get(i).setIndentLevel(1); } box2.setAnchor(new Rectangle(36, 80, 648, 400)); }
public static void slide11(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.TITLE); box1.setText("HSLF Development Plans"); box1.setAnchor(new Rectangle(36, 21, 648, 90)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.BODY); box2.setText( "Support for more PowerPoint functionality\r" + "Rendering slides into java.awt.Graphics2D\r" + "A way to export slides into images or other formats\r" + "Integration with Apache FOP - Formatting Objects Processor\r" + "Transformation of XSL-FO into PPT\r" + "PPT2PDF transcoder" ); List<? extends TextParagraph<?,?,?>> tp = box2.getTextParagraphs(); for (int i : new byte[]{0,1,3}) { tp.get(i).getTextRuns().get(0).setFontSize(28d); } for (int i : new byte[]{2,4,5}) { tp.get(i).getTextRuns().get(0).setFontSize(24d); tp.get(i).setIndentLevel(1); } box2.setAnchor(new Rectangle(36, 126, 648, 400)); }
public static void slide1(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.CENTER_TITLE); box1.setText("POI-HSLF"); box1.setAnchor(new Rectangle(54, 78, 612, 115)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY); box2.setText("Java API To Access Microsoft PowerPoint Format Files"); box2.setAnchor(new Rectangle(108, 204, 504, 138)); TextBox<?,?> box3 = slide.createTextBox(); box3.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(32d); box3.setText( "Yegor Kozlov\r" + "yegor - apache - org"); box3.setHorizontalCentered(true); box3.setAnchor(new Rectangle(206, 348, 310, 84)); }
public static void slide7(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box2 = slide.createTextBox(); box2.setHorizontalCentered(true); box2.setVerticalAlignment(VerticalAlignment.MIDDLE); box2.setText("Java Code"); box2.setFillColor(new Color(187, 224, 227)); box2.setStrokeStyle(0.75, Color.black); box2.setAnchor(new Rectangle(66, 243, 170, 170)); TextBox<?,?> box3 = slide.createTextBox(); box3.setHorizontalCentered(true); box3.setVerticalAlignment(VerticalAlignment.MIDDLE); box3.setText("*.ppt file"); box3.setFillColor(new Color(187, 224, 227)); box3.setStrokeStyle(0.75, Color.black); box3.setAnchor(new Rectangle(473, 243, 170, 170)); AutoShape<?,?> box4 = slide.createAutoShape(); box4.setShapeType(ShapeType.RIGHT_ARROW); box4.setFillColor(new Color(187, 224, 227)); box4.setStrokeStyle(0.75, Color.black); box4.setAnchor(new Rectangle(253, 288, 198, 85)); }
public static void slide9(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide();
public static void slide6(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide();
HSLFSlideShow ss = HSLFSlideShow.create(); SlideShow ppt = new SlideShow(ss); Slide slide = ppt.createSlide();
public static void slide4(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide();