|
@@ -17,6 +17,7 @@
|
|
package org.springblade.resource.endpoint;
|
|
package org.springblade.resource.endpoint;
|
|
|
|
|
|
import com.aspose.cells.SaveFormat;
|
|
import com.aspose.cells.SaveFormat;
|
|
|
|
+import com.aspose.words.DocumentBuilder;
|
|
import com.itextpdf.text.Image;
|
|
import com.itextpdf.text.Image;
|
|
import com.itextpdf.text.Rectangle;
|
|
import com.itextpdf.text.Rectangle;
|
|
import com.itextpdf.text.pdf.PdfWriter;
|
|
import com.itextpdf.text.pdf.PdfWriter;
|
|
@@ -265,35 +266,34 @@ public class OssEndpoint {
|
|
* @return 上传结果对象
|
|
* @return 上传结果对象
|
|
*/
|
|
*/
|
|
private NewBladeFile wordToPdf(String originalFilename, InputStream is){
|
|
private NewBladeFile wordToPdf(String originalFilename, InputStream is){
|
|
-// String pdfFileUrl = "";
|
|
|
|
-// int page = 0;
|
|
|
|
-// try{
|
|
|
|
-// com.aspose.words.Document document = new com.aspose.words.Document(is);
|
|
|
|
-//
|
|
|
|
-// DocumentBuilder documentBuilder = new DocumentBuilder(document);
|
|
|
|
-// com.aspose.words.Font font = documentBuilder.getFont();
|
|
|
|
-//
|
|
|
|
-// font.setName("宋体");
|
|
|
|
-//
|
|
|
|
-// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
-// document.save(bos,com.aspose.words.SaveFormat.PDF);
|
|
|
|
-//
|
|
|
|
-// //上传文件
|
|
|
|
-// InputStream pdfInput = new ByteArrayInputStream(bos.toByteArray());
|
|
|
|
-// BladeFile bladeFile = this.ossBuilder.template().putFile(originalFilename,pdfInput);
|
|
|
|
-// pdfFileUrl = bladeFile.getLink();
|
|
|
|
-//
|
|
|
|
-// //获取页数
|
|
|
|
-// page = document.getPageCount();
|
|
|
|
-//
|
|
|
|
-// }catch (Exception e){
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// NewBladeFile newBladeFile = new NewBladeFile();
|
|
|
|
-// newBladeFile.setPdfUrl(pdfFileUrl);
|
|
|
|
-// newBladeFile.setPage(page);
|
|
|
|
-// return newBladeFile;
|
|
|
|
- return null;
|
|
|
|
|
|
+ String pdfFileUrl = "";
|
|
|
|
+ int page = 0;
|
|
|
|
+ try{
|
|
|
|
+ com.aspose.words.Document document = new com.aspose.words.Document(is);
|
|
|
|
+
|
|
|
|
+ DocumentBuilder documentBuilder = new DocumentBuilder(document);
|
|
|
|
+ com.aspose.words.Font font = documentBuilder.getFont();
|
|
|
|
+
|
|
|
|
+ font.setName("宋体");
|
|
|
|
+
|
|
|
|
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
+ document.save(bos,com.aspose.words.SaveFormat.PDF);
|
|
|
|
+
|
|
|
|
+ //上传文件
|
|
|
|
+ InputStream pdfInput = new ByteArrayInputStream(bos.toByteArray());
|
|
|
|
+ BladeFile bladeFile = this.ossBuilder.template().putFile(originalFilename,pdfInput);
|
|
|
|
+ pdfFileUrl = bladeFile.getLink();
|
|
|
|
+
|
|
|
|
+ //获取页数
|
|
|
|
+ page = document.getPageCount();
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ NewBladeFile newBladeFile = new NewBladeFile();
|
|
|
|
+ newBladeFile.setPdfUrl(pdfFileUrl);
|
|
|
|
+ newBladeFile.setPage(page);
|
|
|
|
+ return newBladeFile;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|