编程语言
首页 > 编程语言> > java中使用openoffice工具word转pdf

java中使用openoffice工具word转pdf

作者:互联网

        版本:Apache_OpenOffice_4.1.5_Win_x86_install_zh-CN.exe

<dependency>
   <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-core</artifactId>
    <version>4.2.2</version>
</dependency>
<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-spring-boot-starter</artifactId>
    <version>4.2.2</version>
</dependency>
<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-local</artifactId>
    <version>4.2.2</version>
</dependency>
jodconverter:
  local:
    enabled: true
    office-home: "C:\\Program Files (x86)\\OpenOffice 4"  #本地安装openoffice的路径
    max-tasks-per-process: 10
    port-numbers: 8100
    @Autowired
    private DocumentConverter converter;


    /**
     * word转pdf
     * @param input word文件输入路径
     * @param output pdf文件输出路径
     */
    @ApiOperation(value = "wordtopdf")
    @RequestMapping(value = "/wordtopdf", method = RequestMethod.GET)
    public void wordtopdf(@RequestParam(name = "input") String input,@RequestParam(name = "output") String output) {
        File inputFile = new File(input);
        File outputFile = new File(output);
        try {
            converter.convert(inputFile).to(outputFile).execute();
        } catch (OfficeException e) {
            e.printStackTrace();
        }
    }

参考文章:

SpringBoot集成jodconverter使用openoffice将word转为pdf - 简书

Java实现word文档转换为pdf,jodconverter_XIA_1997的博客-CSDN博客_java pdfconverter

标签:java,output,word,jodconverter,openoffice,input,pdf
来源: https://blog.csdn.net/qq_39954604/article/details/121205812