为了账号安全,请及时绑定邮箱和手机立即绑定

documents4j 转换为 pdf 没有 Microsoft word 就不能工作?

documents4j 转换为 pdf 没有 Microsoft word 就不能工作?

慕沐林林 2023-04-26 15:01:41
我想用 documents4j 将 docx 文件转换为 pdf,但我不想使用 MS word有没有其他解决方案?我使用 Apache poi 但它在波斯语中无法正常工作public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {    ByteArrayOutputStream bo = new ByteArrayOutputStream();    InputStream in = new BufferedInputStream(new FileInputStream("d:\\c.docx"));    IConverter converter = LocalConverter.builder()            .baseFolder(new File("D:\\a"))            .workerPool(20, 25, 2, TimeUnit.SECONDS)            .processTimeout(5, TimeUnit.SECONDS)            .build();    Future<Boolean> conversion = converter            .convert(in).as(DocumentType.MS_WORD)            .to(bo).as(DocumentType.PDF)            .prioritizeWith(1000) // optional            .schedule();    conversion.get();    try (OutputStream outputStream = new FileOutputStream("D:\\c.pdf")) {        bo.writeTo(outputStream);    } catch (IOException e) {        e.printStackTrace();    }    in.close();    bo.close();}}
查看完整描述

1 回答

?
千万里不及你

TA贡献1784条经验 获得超9个赞

documents4j 是一个通过桥梁将文档转换为 MS Word 的工具。不幸的是,如果您没有运行实例,这将不起作用。



查看完整回答
反对 回复 2023-04-26
  • 1 回答
  • 0 关注
  • 302 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信