word 转pdf poi4.1.2 报错

poi4.1.2 引入了 包   在fr包中剔除出去   poi-ooxml
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.poi.xwpf.converter.pdf-gae</artifactId>
<version>2.0.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
</exclusions>
</dependency>


<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
 
 
 
Resource resource = new ClassPathResource("tempExcel" +System.getProperty("file.separator")+"20240506.docx");
InputStream fileinputStream = resource.getInputStream();
 
XWPFDocument document = new XWPFDocument(fileinputStream);
// 转换为PDF
PdfOptions options = PdfOptions.create();
PdfConverter.getInstance().convert(document, outputStream, options);
byte[] buffer =outputStream.toByteArray();
InputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
 
这样  word 转成pdf 的 文件流 byteArrayInputStream 就拿到了
 
 
 
posted @ 2024-06-25 13:50  雪儿蛇王  阅读(67)  评论(0编辑  收藏  举报