https://bz.apache.org/bugzilla/show_bug.cgi?id=60454

Mark Murphy <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Mark Murphy <[email protected]> ---
This works for me:

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.xwpf.usermodel.VerticalAlign;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;

public class TestVerticalAlign {

        public static void main(String[] args) {
                XWPFDocument doc = new XWPFDocument();
                XWPFParagraph p = doc.createParagraph();
                XWPFRun r = p.createRun();
                r.setText("This is some Text");
                r = p.createRun();
                r.setSubscript(VerticalAlign.SUBSCRIPT);
                r.setText(" This is subscript text");
                r = p.createRun();
                r.setSubscript(VerticalAlign.SUPERSCRIPT);
                r.setText(" This is superscript text");

                XWPFParagraph p2 = doc.createParagraph();
                r = p2.createRun();
                for (XWPFRun r2 : p.getRuns()) {
                        switch (r2.getSubscript()) {
                        case BASELINE:
                                r.addCarriageReturn();
                                r.setText("Normal Text");
                                break;
                        case SUBSCRIPT:
                                r.addCarriageReturn();
                                r.setText("Subscript Text");
                                break;
                        case SUPERSCRIPT:
                                r.addCarriageReturn();
                                r.setText("Superscript Text");
                                break;
                        default:
                                r.addCarriageReturn();
                                r.setText("Unknown Text Alignment");
                                break;
                        }
                }

                // Write the Document in file system
                try {
                        FileOutputStream out = new FileOutputStream(new File(
                                        "valigntest.docx"));
                        doc.write(out);
                        out.close();
                        doc.close();
                        System.out.println("valigntest.docx written
successully");
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                }
        }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to