aspose实现Office转Pdf关键代码 博客分类: OfficeToPdf javaaspose
程序员文章站
2024-02-25 23:44:03
...
aspose实现Office转Pdf关键代码:
jar包:
aspose-words-14.6.0.jar
aspose-cells-10.8.jar
aspose.slides-14.4.0.jar
aspose-diagram-2.1.0.jar
jar包:
aspose-words-14.6.0.jar
aspose-cells-10.8.jar
aspose.slides-14.4.0.jar
aspose-diagram-2.1.0.jar
protected void realTransform(InputStream in, OutputStream out) throws IOException { String lowerFileName = this.fileName.toLowerCase(); try { if ((lowerFileName.endsWith(".xls")) || (lowerFileName.endsWith(".xlsx")) || (lowerFileName.endsWith(".csv"))) { Workbook workbook = new Workbook(in); workbook.save(out, 13); } else if ((lowerFileName.endsWith(".doc")) || (lowerFileName.endsWith(".docx")) || (lowerFileName.endsWith(".rtf"))) { Document doc = new Document(in); doc.save(out, 40); } else if ((lowerFileName.endsWith(".ppt")) || (lowerFileName.endsWith(".pptx")) || (lowerFileName.endsWith(".pps")) || (lowerFileName.endsWith(".ppsx"))) { Presentation ppt = new Presentation(in); ppt.save(out, 1); } else if ((lowerFileName.endsWith(".vdx")) || (lowerFileName.endsWith(".vsx")) || (lowerFileName.endsWith(".vtx")) || (lowerFileName.endsWith(".vsd"))) { Diagram visio = new Diagram(in); visio.save(out, 8); } } catch (Exception ex) { throw new RuntimeException(ex); } }