https://bz.apache.org/bugzilla/show_bug.cgi?id=58237
Bug ID: 58237
Summary: Unable to add image to a word document header using
XWPF
Product: POI
Version: 3.12-FINAL
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: XWPF
Assignee: [email protected]
Reporter: [email protected]
I have a requirement to add image to header of a word document file (.docx)
I tried using the available API methods to do so (passed inputstream of image
and XWPFDocument for both but none of the two approaches worked):
Approach1:
------------
XWPFHeaderFooterPolicy headerFooterPolicy = document
.getHeaderFooterPolicy();
XWPFHeader defaultHeader = headerFooterPolicy.getDefaultHeader();
defaultHeader.getParagraphs().get(0).getRuns().get(0).addPicture(is,
Document.PICTURE_TYPE_JPEG, "test.jpg", 100, 100);
Approach 2:
-----------
CTP ctp = CTP.Factory.newInstance();
CTR ctr = ctp.addNewR();
CTRPr rpr = ctr.addNewRPr();
XWPFParagraph imagePara = new XWPFParagraph(ctp, document);
imagePara.createRun().addPicture(is, Document.PICTURE_TYPE_JPEG, "test.jpg",
50, 50);
XWPFParagraph[] imaheparagraphs = new XWPFParagraph[1];
imaheparagraphs[0]=imagePara;
headerFooterPolicy.createHeader( STHdrFtr.DEFAULT,imaheparagraphs);
I am able to add an image to body but not able to find a way to do the same to
the header even though POI has methods that suggest that it should.
Thanks.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]