[英]java.lang.ClassNotFoundException: org.apache.poi.xwpf.usermodel.IRunBody
I am trying to convert docx to pdf using xdocreport but I end up with classnot found exception for the class IRunBody. 我正在尝试使用xdocreport将docx转换为pdf,但最终导致类IRunBody的classnot found异常。 My package 'org.apache.poi.xwpf.usermodel' doesnt seem to have this interface.
我的软件包“ org.apache.poi.xwpf.usermodel”似乎没有此接口。 I have all the required jars for this.
我已经准备好了所有需要的罐子。 poi, poi-ooxml, poi-ooxml-schemas and yet I am unable to get this class.
poi,poi-ooxml,poi-ooxml-schemas,但我无法获得此类。 Can anyone let me know what am I missing here?
谁能告诉我我在这里想念什么吗? Any other jars that I need to add?
我需要添加其他罐子吗? Below is the code that I am runnig
下面是我运行的代码
XWPFDocument xwpfDoc = new XWPFDocument(new FileInputStream(fileName));
PdfOptions options = PdfOptions.create().fontEncoding("windows-1250");
String randomFilename = UUID.randomUUID().toString();
String outputFIlePath = TEMPORARY_PDF_FILE_LOCATION + randomFilename + ".pdf";
OutputStream output = new FileOutputStream(outputFIlePath);
PdfConverter.getInstance().convert(xwpfDoc, output, options);
My ooxml jar was not latest. 我的ooxml jar不是最新的。 After updating ooxml jar, the issue was resolved.
更新ooxml jar之后,此问题已解决。 Thank you.
谢谢。
I had exactly same problem. 我有完全一样的问题。 And I resolved it!
我解决了!
Because my project is not Maven, I could not use nice Dependencies maven resolver - what I did is 1) just temporary I created new empty Maven project; 因为我的项目不是Maven,所以我不能使用依赖项maven解析器-我所做的是1)只是临时的,我创建了一个新的空Maven项目; 2) in pom.xml I add just these 3 required for my needs libraries:
2)在pom.xml中,我只添加了我的需求库所需的以下3个:
<dependencies>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>org.apache.poi.xwpf.converter.pdf</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
<version>1.0.5</version>
</dependency>
</dependencies>
3) Updated this Maven project, so it downloaded all these libraries and all of its dependencies, so I have got this jars : 3)更新了这个Maven项目,因此它下载了所有这些库及其所有依赖项,所以我得到了这个jars :
4) Then just copied these jars to my real project and it worked!
4)然后将这些罐子复制到我的真实项目中,就可以了!
I recommend you to do same thing, instead of trying to solve dependencies manually. 我建议您做同样的事情,而不是尝试手动解决依赖关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.