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());
}
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());
}
Aggregations