引入依赖,低版本的报错,2.0.2能够实现转换
<dependency>
<groupId>org.ofdrw</groupId>
<artifactId>ofdrw-converter</artifactId>
<version>2.0.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
代码实现
import org.ofdrw.converter.ConvertHelper;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* @Description: ofd格式转pdf
* @author: Be.insighted
* @create: 2024/9/21 10:03
* @since 1.0.0
*/
public class OFDToPDFUtil {
public static void main(String[] args) throws IOException {
File ofdFile = new File("D:\\下载-浏览器\\dzfp_岳易楼 食府_20240920191050.ofd");
Path pdfPath = Paths.get("D:\\下载-浏览器\\dzfp_岳易楼 食府_20240920191050.pdf");
ConvertHelper.toPdf(ofdFile.toPath(), pdfPath);
}
}