Examples of XWPFParagraph


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

    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

    @Test
    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

        CTTextPath shapeTextPath = shape.addNewTextpath();
        shapeTextPath.setStyle("font-family:"Cambria";font-size:1pt");
        shapeTextPath.setString(text);
        pict.set(group);
        // end watermark paragraph
        return new XWPFParagraph(p, doc);
    }
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

                extractHeaders(text, hfPolicy);
   
    // First up, all our paragraph based text
    Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while(i.hasNext()) {
                        XWPFParagraph paragraph = i.next();


                        try {
                                CTSectPr ctSectPr = null;
                                if (paragraph.getCTP().getPPr()!=null) {
                                        ctSectPr = paragraph.getCTP().getPPr().getSectPr();
                                }

                                XWPFHeaderFooterPolicy headerFooterPolicy = null;

                                if (ctSectPr!=null) {
View Full Code Here

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

    CTTextPath shapeTextPath = shape.addNewTextpath();
    shapeTextPath.setStyle("font-family:&quot;Cambria&quot;;font-size:1pt");
    shapeTextPath.setString(text);
    pict.set(group);
    // end watermark paragraph
    return new XWPFParagraph(p);
  }
View Full Code Here

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

    CTTextPath shapeTextPath = shape.addNewTextpath();
    shapeTextPath.setStyle("font-family:&quot;Cambria&quot;;font-size:1pt");
    shapeTextPath.setString(text);
    pict.set(group);
    // end watermark paragraph
    return new XWPFParagraph(p, null);
  }
View Full Code Here

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

    extractHeaders(text, hfPolicy);
   
    // First up, all our paragraph based text
    Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while(i.hasNext()) {
      XWPFParagraph paragraph = i.next();

      try {
        CTSectPr ctSectPr = null;
        if (paragraph.getCTP().getPPr()!=null) {
          ctSectPr = paragraph.getCTP().getPPr().getSectPr();
        }

        XWPFHeaderFooterPolicy headerFooterPolicy = null;

        if (ctSectPr!=null) {
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.