("F:\\poi笔记.docx"); XWPFDocument xwpfDocument = new XWPFDocument(fileInputStream); PdfOptions pdfOptions = PdfOptions.create(); FileOutputStream fileOutputStream = new FileOutputStream("F:\\poi笔记.pdf"); PdfConverter.getInstance().convert(xwpfDocument,fileOutputStream,pdfOptions); fileInput...
converter.convert(inputFile, outputFile); // 关闭连接 connection.disconnect(); // 关闭进程 p.destroy(); } public static void main(String[] args) { String start = "F:\\新建文件夹\\我是word测试文件.docx"; String over = "F:\\新建文件夹\\成了.pdf"; try { WordToPDF(start, over); ...
第一步 添加maven依赖 需注意:此处引用的版本为2.2.1版本,不支持.docx文件的转换,若需要转换.docx文件需2.2.2及以上版本,但maven库没有此版本需自行下载导入jar包 com.artofsolving jodconverter 2.2.1 第二步 编写后台代码 // word文件路径 String sourceFile = “C:\\Users\\dev\\Desktop\\template.docx”...
connect(); // 转换word到pdf DocumentConverter converter = new OpenOfficeDocumentConverter( connection); converter.convert(inputFile, outputFile); System.out.println("转换完成!"); } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { // 关闭连接 connection....
pdfGenerator.generatePDFFromDocxURL("http://your_url_here.docx","c:/pdfgenerator-test1.pdf","A4","Portrait"); Here you can find major details on convertingDocx to PDF in Java with the Sferyx PDF Generator. Convert Word Docx to PDF in Java from URL to java.io.OutputStream ...
converter.convert(inputFile, outputFile); // 关闭连接 connection.disconnect(); // 关闭进程 p.destroy(); } public static void main(String[] args) { String start = "F:\\新建文件夹\\我是word测试文件.docx"; String over = "F:\\新建文件夹\\成了.pdf"; ...
public class FileConvertUtil { /** 默认转换后文件后缀 */ private static final String DEFAULT_SUFFIX = "pdf"; /** openoffice_port */ private static final Integer OPENOFFICE_PORT = 8100; /** * 方法描述 office文档转换为PDF(处理本地文件) ...
public void convert(File docFile, File destFile) { try { documentConverter.convert(docFile).to(destFile).execute(); } catch (OfficeException e) { log.error("openoffice文件转换pdf失败,源文件:{},异常信息:",docFile.getPath(),e);
Create a PDF FileThese samples illustrate how to convert files of supported formats to PDF. Refer the Create PDF API documentation to see the list of all supported media types which can be converted to PDF.Create a PDF File From a DOCX FileThe sample class CreatePDFFromDOCX creates a PDF ...
I have just started using Spire.Doc for Java in order to convert some DOCX files to PDF but the outcome files layouts are broken. I am attaching the source and the output files and I was wondering if you could help us. With spire.doc 2.10.3 the converted PDF file did not keep the ...