Search in sources :

Example 16 with XWPFHeaderFooterPolicy

use of org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy in project poi by apache.

the class TestXWPFHeader method testSetWatermark.

@Test
public void testSetWatermark() throws IOException {
    XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx");
    // No header is set (yet)
    XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
    assertNull(policy.getDefaultHeader());
    assertNull(policy.getFirstPageHeader());
    assertNull(policy.getDefaultFooter());
    policy.createWatermark("DRAFT");
    assertNotNull(policy.getDefaultHeader());
    assertNotNull(policy.getFirstPageHeader());
    assertNotNull(policy.getEvenPageHeader());
    // Re-open, and check
    XWPFDocument reopened = XWPFTestDataSamples.writeOutAndReadBack(sampleDoc);
    policy = reopened.getHeaderFooterPolicy();
    assertNotNull(policy.getDefaultHeader());
    assertNotNull(policy.getFirstPageHeader());
    assertNotNull(policy.getEvenPageHeader());
}
Also used : XWPFHeaderFooterPolicy(org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy) Test(org.junit.Test)

Example 17 with XWPFHeaderFooterPolicy

use of org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy in project poi by apache.

the class TestXWPFPictureData method verifyOneHeaderPicture.

private void verifyOneHeaderPicture(XWPFDocument sampleDoc) {
    XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
    XWPFHeader header = policy.getDefaultHeader();
    List<XWPFPictureData> pictures = header.getAllPictures();
    assertEquals(1, pictures.size());
}
Also used : XWPFHeaderFooterPolicy(org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy)

Aggregations

XWPFHeaderFooterPolicy (org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy)17 Test (org.junit.Test)5 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)3 XWPFRun (org.apache.poi.xwpf.usermodel.XWPFRun)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 XWPFCommentsDecorator (org.apache.poi.xwpf.model.XWPFCommentsDecorator)2 IRunElement (org.apache.poi.xwpf.usermodel.IRunElement)2 XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)2 XWPFHyperlink (org.apache.poi.xwpf.usermodel.XWPFHyperlink)2 XWPFHyperlinkRun (org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 XmlObject (org.apache.xmlbeans.XmlObject)2 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)2 CTSectPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr)2 CTText (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 QName (javax.xml.namespace.QName)1