Example usage for org.apache.poi.xslf.usermodel XSLFTextRun createHyperlink

List of usage examples for org.apache.poi.xslf.usermodel XSLFTextRun createHyperlink

Introduction

In this page you can find the example usage for org.apache.poi.xslf.usermodel XSLFTextRun createHyperlink.

Prototype

@Override
    public XSLFHyperlink createHyperlink() 

Source Link

Usage

From source file:poi.xslf.usermodel.Tutorial6.java

License:Apache License

public static void main(String[] args) throws IOException {
    XMLSlideShow ppt = new XMLSlideShow();

    XSLFSlide slide1 = ppt.createSlide();
    XSLFSlide slide2 = ppt.createSlide();

    XSLFTextBox shape1 = slide1.createTextBox();
    shape1.setAnchor(new Rectangle(50, 50, 200, 50));
    XSLFTextRun r1 = shape1.addNewTextParagraph().addNewTextRun();
    XSLFHyperlink link1 = r1.createHyperlink();
    r1.setText("http://poi.apache.org"); // visible text
    link1.setAddress("http://poi.apache.org"); // link address

    XSLFTextBox shape2 = slide1.createTextBox();
    shape2.setAnchor(new Rectangle(300, 50, 200, 50));
    XSLFTextRun r2 = shape2.addNewTextParagraph().addNewTextRun();
    XSLFHyperlink link2 = r2.createHyperlink();
    r2.setText("Go to the second slide"); // visible text
    link2.setAddress(slide2); // link address

    FileOutputStream out = new FileOutputStream("hyperlinks.pptx");
    ppt.write(out);/*from  www.j a  v  a  2s.  co  m*/
    out.close();
}