public XWPFHeader CreateHeader(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation header        = XWPFRelation.HEADER;
            string       pStyle        = "Header";
            int          relationIndex = this.GetRelationIndex(header);
            HdrDocument  hdrDocument   = new HdrDocument();
            XWPFHeader   relationship  = (XWPFHeader)this.doc.CreateRelationship((POIXMLRelation)header, (POIXMLFactory)XWPFFactory.GetInstance(), relationIndex);
            CT_HdrFtr    headerFooter  = this.buildHdr(type, pStyle, (XWPFHeaderFooter)relationship, pars);

            relationship.SetHeaderFooter(headerFooter);
            Stream outputStream = relationship.GetPackagePart().GetOutputStream();

            hdrDocument.SetHdr((CT_Hdr)headerFooter);
            this.assignHeader(relationship, type);
            hdrDocument.Save(outputStream, this.Commit((XWPFHeaderFooter)relationship));
            outputStream.Close();
            return(relationship);
        }
Exemplo n.º 2
0
        public XWPFHeader CreateHeader(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation relation = XWPFRelation.HEADER;
            String       pStyle   = "Header";
            int          i        = GetRelationIndex(relation);
            HdrDocument  hdrDoc   = new HdrDocument();
            XWPFHeader   wrapper  = (XWPFHeader)doc.CreateRelationship(relation, XWPFFactory.GetInstance(), i);

            CT_HdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);

            wrapper.SetHeaderFooter(hdr);

            hdrDoc.SetHdr((CT_Hdr)hdr);

            assignHeader(wrapper, type);
            using (Stream outputStream = wrapper.GetPackagePart().GetOutputStream())
            {
                hdrDoc.Save(outputStream);
            }
            return(wrapper);
        }