本文整理了Java中org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.getHeader()
方法的一些代码示例,展示了XWPFHeaderFooterPolicy.getHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFHeaderFooterPolicy.getHeader()
方法的具体详情如下:
包路径:org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy
类名称:XWPFHeaderFooterPolicy
方法名:getHeader
[英]Get the header that applies to the given (1 based) page.
[中]获取适用于给定(基于1)页面的标题。
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Creates a new header of the specified type, to which the
* supplied (and previously unattached!) paragraphs are
* added to.
*/
public XWPFHeader createHeader(Enum type, XWPFParagraph[] pars) {
XWPFHeader header = getHeader(type);
if (header == null) {
HdrDocument hdrDoc = HdrDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.HEADER;
int i = getRelationIndex(relation);
XWPFHeader wrapper = (XWPFHeader) doc.createRelationship(relation,
XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
CTHdrFtr hdr = buildHdr(type, wrapper, pars);
wrapper.setHeaderFooter(hdr);
hdrDoc.setHdr(hdr);
assignHeader(wrapper, type);
header = wrapper;
}
return header;
}
代码示例来源:origin: ekoz/kbase-doc
private void addWaterMark(Object obj, String watermark, String color) {
if (obj instanceof XWPFDocument) {
XWPFDocument doc = (XWPFDocument) obj;
// create header-footer
XWPFHeaderFooterPolicy headerFooterPolicy = doc.getHeaderFooterPolicy();
if (headerFooterPolicy == null) headerFooterPolicy = doc.createHeaderFooterPolicy();
// create default Watermark - fill color black and not rotated
headerFooterPolicy.createWatermark(watermark);
// get the default header
// Note: createWatermark also sets FIRST and EVEN headers
// but this code does not updating those other headers
XWPFHeader header = headerFooterPolicy.getHeader(XWPFHeaderFooterPolicy.DEFAULT);
XWPFParagraph paragraph = header.getParagraphArray(0);
// get com.microsoft.schemas.vml.CTShape where fill color and rotation is set
XmlObject[] xmlobjects = paragraph.getCTP().getRArray(0).getPictArray(0).selectChildren(new QName("urn:schemas-microsoft-com:vml", "shape"));
if (xmlobjects.length > 0) {
com.microsoft.schemas.vml.CTShape ctshape = (com.microsoft.schemas.vml.CTShape)xmlobjects[0];
// set fill color
ctshape.setFillcolor(color);
// set rotation
ctshape.setStyle(ctshape.getStyle() + ";rotation:315");
}
} else if (obj instanceof HWPFDocument) {
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Creates a new header of the specified type, to which the
* supplied (and previously unattached!) paragraphs are
* added to.
*/
public XWPFHeader createHeader(Enum type, XWPFParagraph[] pars) {
XWPFHeader header = getHeader(type);
if (header == null) {
HdrDocument hdrDoc = HdrDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.HEADER;
int i = getRelationIndex(relation);
XWPFHeader wrapper = (XWPFHeader) doc.createRelationship(relation,
XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
CTHdrFtr hdr = buildHdr(type, wrapper, pars);
wrapper.setHeaderFooter(hdr);
hdrDoc.setHdr(hdr);
assignHeader(wrapper, type);
header = wrapper;
}
return header;
}
内容来源于网络,如有侵权,请联系作者删除!