Management.PruebaDoc.java Source code

Java tutorial

Introduction

Here is the source code for Management.PruebaDoc.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Management;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.poi.xwpf.usermodel.Borders;
import org.apache.poi.xwpf.usermodel.BreakType;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.TextAlignment;
import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;

/**
 *
 * @author hilsierivan
 */
public class PruebaDoc {

    public static void main(String[] args) throws IOException {

        XWPFDocument doc = new XWPFDocument();

        XWPFParagraph p3 = doc.createParagraph();
        XWPFRun r4 = p3.createRun();
        r4.setTextPosition(20);
        r4.setText("To be, or not to be: that is the question: " + "Whether 'tis nobler in the mind to suffer "
                + "The slings and arrows of outrageous fortune, " + "Or to take arms against a sea of troubles, "
                + "And by opposing end them? To die: to sleep; ");
        r4.addBreak(BreakType.PAGE);
        r4.setText("No more; and by a sleep to say we end " + "The heart-ache and the thousand natural shocks "
                + "That flesh is heir to, 'tis a consummation " + "Devoutly to be wish'd. To die, to sleep; "
                + "To sleep: perchance to dream: ay, there's the rub; " + ".......");
        r4.setItalic(true);

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(
                    "C:\\Users\\hilsierivan\\Documents\\NetBeansProjects\\StickMaps\\web\\MapImages\\simple.docx");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(PruebaDoc.class.getName()).log(Level.SEVERE, null, ex);
        }
        doc.write(out);
        out.close();

    }
}