Examples of XWPFParagraph


Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    }

    public void testIntegration() throws Exception {
        XWPFDocument doc = new XWPFDocument();

        XWPFParagraph p1 = doc.createParagraph();

        XWPFRun r1 = p1.createRun();
        r1.setText("Lorem ipsum dolor sit amet.");
        doc.enforceCommentsProtection();

        File tempFile = TempFile.createTempFile("documentProtectionFile", ".docx");
        FileOutputStream out = new FileOutputStream(tempFile);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

      hyperlink = XWPFTestDataSamples.openSampleDocument("TestDocument.docx");
      comments = XWPFTestDataSamples.openSampleDocument("WordWithAttachments.docx");
   }

   public void testHyperlink() {
      XWPFParagraph ps;
      XWPFParagraph ph;
      assertEquals(7, simple.getParagraphs().size());
      assertEquals(5, hyperlink.getParagraphs().size());

      // Simple text
      ps = simple.getParagraphs().get(0);
      assertEquals("I am a test document", ps.getParagraphText());
      assertEquals(1, ps.getRuns().size());

      ph = hyperlink.getParagraphs().get(4);
      assertEquals("We have a hyperlink here, and another.", ph.getParagraphText());
      assertEquals(3, ph.getRuns().size());


      // The proper way to do hyperlinks(!)
      assertFalse(ps.getRuns().get(0) instanceof XWPFHyperlinkRun);
      assertFalse(ph.getRuns().get(0) instanceof XWPFHyperlinkRun);
      assertTrue(ph.getRuns().get(1) instanceof XWPFHyperlinkRun);
      assertFalse(ph.getRuns().get(2) instanceof XWPFHyperlinkRun);

      XWPFHyperlinkRun link = (XWPFHyperlinkRun)ph.getRuns().get(1);
      assertEquals("http://poi.apache.org/", link.getHyperlink(hyperlink).getURL());


      // Test the old style decorator
      // You probably don't want to still be using it...
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    wordDoc =
      DocumentDocument.Factory.parse(getCorePart().getInputStream());
   
    // filling paragraph list
    for (CTP p : getDocumentBody().getPArray())  {
      paragraphs.add(new XWPFParagraph(p, this));
    }

    // Get the hyperlinks
    // TODO: make me optional/separated in private function
    try  {
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    public XWPFTable(CTTbl table) {
        for(CTRow row : table.getTrArray()) {
          StringBuffer rowText = new StringBuffer();
            for(CTTc cell : row.getTcArray()) {
                for(CTP ctp : cell.getPArray()) {
                    XWPFParagraph p = new XWPFParagraph(ctp);
                    if(rowText.length() > 0) {
                      rowText.append('\t');
                    }
                    rowText.append(p.getText());
                }
            }
            if(rowText.length() > 0) {
              this.text.append(rowText);
              this.text.append('\n');
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    public XWPFTable(CTTbl table) {
        for(CTRow row : table.getTrArray()) {
          StringBuffer rowText = new StringBuffer();
            for(CTTc cell : row.getTcArray()) {
                for(CTP ctp : cell.getPArray()) {
                    XWPFParagraph p = new XWPFParagraph(ctp, null);
                    if(rowText.length() > 0) {
                      rowText.append('\t');
                    }
                    rowText.append(p.getText());
                }
            }
            if(rowText.length() > 0) {
              this.text.append(rowText);
              this.text.append('\n');
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    private void extractIBodyText(IBody bodyElement, XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
       for(IBodyElement element : bodyElement.getBodyElements()) {
          if(element instanceof XWPFParagraph) {
             XWPFParagraph paragraph = (XWPFParagraph)element;
             extractParagraph(paragraph, xhtml);
          }
          if(element instanceof XWPFTable) {
             XWPFTable table = (XWPFTable)element;
             extractTable(table, xhtml);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    private void extractIBodyText(IBody bodyElement, XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
       for(IBodyElement element : bodyElement.getBodyElements()) {
          if(element instanceof XWPFParagraph) {
             XWPFParagraph paragraph = (XWPFParagraph)element;
             extractParagraph(paragraph, xhtml);
          }
          if(element instanceof XWPFTable) {
             XWPFTable table = (XWPFTable)element;
             extractTable(table, xhtml);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    private void extractIBodyText(IBody bodyElement, XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
       for(IBodyElement element : bodyElement.getBodyElements()) {
          if(element instanceof XWPFParagraph) {
             XWPFParagraph paragraph = (XWPFParagraph)element;
             extractParagraph(paragraph, xhtml);
          }
          if(element instanceof XWPFTable) {
             XWPFTable table = (XWPFTable)element;
             extractTable(table, xhtml);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

          xhtml.characters(footnameText + "\n");
       }

       // Also extract any paragraphs embedded in text boxes:
       for (XmlObject embeddedParagraph : paragraph.getCTP().selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' declare namespace wps='http://schemas.microsoft.com/office/word/2010/wordprocessingShape' .//*/wps:txbx/w:txbxContent/w:p")) {
           extractParagraph(new XWPFParagraph(CTP.Factory.parse(embeddedParagraph.xmlText()), paragraph.getBody()), xhtml);
       }

       // Finish this paragraph
       xhtml.endElement(tag);

View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

public class ApacheInsertImage
{
  public static void main(String[] args) throws Exception
  {
    XWPFDocument doc = new XWPFDocument();
        XWPFParagraph p = doc.createParagraph();
       
        String imgFile = "aspose.jpg";
        XWPFRun r = p.createRun();
       
        int format = XWPFDocument.PICTURE_TYPE_JPEG;
        r.setText(imgFile);
        r.addBreak();
        r.addPicture(new FileInputStream(imgFile), format, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 pixels
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.