ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

java word转 pdf

java word转 pdf
        <!-- https://mvnrepository.com/artifact/com.luhuiguo/aspose-words --><dependency><groupId>com.luhuiguo</groupId><artifactId>aspose-words</artifactId><version>22.4</version><type>pom</type></dependency>

代码如下:

package com.sailing.dpm.snam.investigation;import com.aspose.words.Document;
import com.sailing.sdp.exception.support.BusinessException;import java.io.File;
import java.io.FileOutputStream;
public class WordToPdf {/**● @param wordPath word路径● @param pdfPath  pdf输出路径*/public static void textWordToPdf(String wordPath, String pdfPath) {FileOutputStream os = null;try {File file = new File(pdfPath);os = new FileOutputStream(file);Document doc = new Document(wordPath);doc.save(os, com.aspose.words.SaveFormat.PDF);} catch (Exception e) {throw new BusinessException("worldToPdf失败");} finally {if (os != null) {
}}}public static void main(String[] args) throws Exception {String wordPath = "F:\\工作\\PDF字体样式要求.docx";String pdfPath = "F:\\工作\\405nnn23.pdf";textWordToPdf(wordPath, pdfPath);}
}

 效果图如下:

image

 

image

 

返回列表