When word converts pdf, it cannot convert lines.
LoveSeriously opened this issue · comments
xiaolong commented
When word converts pdf, it cannot convert lines.
word:
pom.xml
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.poi.xwpf.converter.pdf</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
java:
public void wordToPdf(MultipartFile file, OutputStream outputStream) {
// 转换
try {
// 使用WORD文档构建XWPFDocument对象
XWPFDocument document = new XWPFDocument(file.getInputStream());
// options
PdfOptions options = PdfOptions.create();
String pdfTmpName = "/tmp/tmp.pdf";
PdfConverter.getInstance().convert(document, new FileOutputStream(pdfTmpName), options);
FileInputStream inputStream = new FileInputStream(pdfTmpName);
IOUtils.copy(inputStream, outputStream);
} catch (OLE2NotOfficeXmlFileException ex) {
throw new RuntimeException("暂时不支持word2003版本!");
} catch (IOException e) {
e.printStackTrace();
}
}