Bug 64348 - createWaterMark IndexOutOfBoundException
Summary: createWaterMark IndexOutOfBoundException
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-14 08:16 UTC by xiaoting233zhang
Modified: 2020-09-27 02:39 UTC (History)
1 user (show)



Attachments
This is my implementation of watermarking, including watermarked service and watermarked ServiceImpl (3.26 KB, text/plain)
2020-09-27 02:39 UTC, HanChong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description xiaoting233zhang 2020-04-14 08:16:32 UTC
Caused by: java.lang.IndexOutOfBoundsException
    ┣ 	at org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTBodyImpl.getPArray(Unknown Source:26)
    ┣ 	at org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.getWatermarkParagraph(XWPFHeaderFooterPolicy.java:432)
    ┣ 	at org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.createWatermark(XWPFHeaderFooterPolicy.java:418)

This happens when the document has nothing.
Comment 1 Sayi 2020-04-14 16:43:54 UTC
(In reply to xiaoting233zhang from comment #0)
> Caused by: java.lang.IndexOutOfBoundsException
>     ┣ 	at
> org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTBodyImpl.
> getPArray(Unknown Source:26)
>     ┣ 	at
> org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.
> getWatermarkParagraph(XWPFHeaderFooterPolicy.java:432)
>     ┣ 	at
> org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.
> createWatermark(XWPFHeaderFooterPolicy.java:418)
> 
> This happens when the document has nothing.

Hi, this problem caused by missing paragraph.

Currently you can first create a paragraph to avoid this problem.
Comment 2 Dominik Stadler 2020-05-14 16:19:55 UTC
Can you provide a small sample document and sample code which reproduces this so we can add a test-case for it.
Comment 3 HanChong 2020-09-27 02:39:26 UTC
Created attachment 37473 [details]
This is my implementation of watermarking, including watermarked service and watermarked ServiceImpl