【工具类】Word 转 PDF

商业版权问题

使用破解版-aspose-words-19.5jdk.jar
https://blog.csdn.net/aley/article/details/127914145

Document wordDoc = new Document(wordFileInputStream);
wordDoc.save(pdfFile, new PdfSaveOptions());

中文乱码问题

在linux中使用会造成中文乱码问题

解决方案:复制全部win字体到服务器,然后在代码里引用路径即可

分页问题

在word文档里面设置好分页符即可,路径:页面布局-分隔符-下一页分节符

边距问题

遍历每一页 wordDoc.getSections(),然后.getPageSetup()设置边距即可

本地 jar 打包-配置

https://www.cnblogs.com/paopaolx/p/16539342.html

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-maven-pluginartifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombokgroupId>
                        <artifactId>lombokartifactId>
                    exclude>
                excludes>

                
                <includeSystemScope>trueincludeSystemScope>
            configuration>
        plugin>
    plugins>
build>

Todolist

转出的PDF需要落地
字体也是读取本地路径

代码路径

https://gitee.com/zhaomingjian/workspace_luoan_demo/tree/master/word2pdf

你可能感兴趣的:(干货,word,pdf)