Docx4j版本8.1.2

HandoutMasterPart的默认构造函数在默认零件名称中不包含前导/。这将自动导致InvalidFormatException。

其他部分确实包含前导/。

HandoutMasterPart handoutMasterPart = new HandoutMasterPart();

> org.docx4j.openpackaging.exceptions.InvalidFormatException: A part
> name shall start with a forward slash ('/') character [M1.4]:
> ppt/handoutMasters/handoutMaster1.xml     at
> org.docx4j.openpackaging.parts.PartName.throwExceptionIfPartNameNotStartsWithForwardSlashChar(PartName.java:453)
>   at
> org.docx4j.openpackaging.parts.PartName.throwExceptionIfInvalidPartUri(PartName.java:221)
>   at org.docx4j.openpackaging.parts.PartName.<init>(PartName.java:161)
>   at org.docx4j.openpackaging.parts.PartName.<init>(PartName.java:133)
>   at
> org.docx4j.openpackaging.parts.PresentationML.HandoutMasterPart.<init>(HandoutMasterPart.java:38)

最佳答案

谢谢你将于本周发布新版本。

在此期间,您可以使用:

HandoutMasterPart handoutMasterPart = new HandoutMasterPart(new PartName("/ppt/handoutMasters/handoutMaster1.xml"));

09-27 11:56