java Doc转Pdf

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录


Doc转Pdf

导入依赖

com.documents4j
documents4j-local
1.1.7


com.documents4j
documents4j-transformer-msoffice-word
1.1.7


com.documents4j
documents4j-transformer-msoffice-powerpoint
1.1.7


com.documents4j
documents4j-transformer-msoffice-excel
1.1.7

代码

public static void main(String[] args) throws Exception {
        IConverter converter = LocalConverter.builder().build();
        docToPdf(converter);
    }
public static void docToPdf(IConverter converter) throws Exception {
        converter.convert(new FileInputStream("D:\\xxdd\\优化需求(三)_20220112.doc"), true)
                .as(DocumentType.DOC)
                .to(new FileOutputStream("D:\\xxdd\\优化需求(三)_20220112.pdf"), true)
                .as(DocumentType.PDF)
                .execute();
    }

版权声明:本文为Sz_t4PtiHCKY原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。