word转pdf

分享个人经验,成功将word.docx转换为pdf,页眉在转换后仍能显示。对比使用openoffice转换,因版本兼容问题,页眉无法在pdf中呈现。
摘要由CSDN通过智能技术生成

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

import com.aspose.words.Document;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import com.sunxung.factoring.component.exception.BusinessException;
import com.sunxung.factoring.component.util.CodeUtil;

public class AsopUtil {

    public static File doc2pdf(String inPath, String outPath) {
        if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
            // return;
            throw new BusinessException(CodeUtil.FAIL, "验证License失败");
        }
        File file = null;
       //outPath = "testFile/test.pdf";
       //inPath="testFile/test.docx";
        try {
            long old = System.currentTimeMillis();
            file = new File(outPath); // 新建一个空白pdf文档
            if (!file.getParentFile().exists()) {
                file.getParentFile()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值