remote server ppt2003 to images
来源:互联网 发布:淘宝有货提醒 编辑:程序博客网 时间:2024/04/29 10:31
private List<String> getPPTImages(String url) { List<String> imageFiles = null; File pptFile = null; FileOutputStream fos = null; ReadableByteChannel rbc = null; HSLFSlideShow ppt = null; BufferedInputStream is = null; InputStream iStream = null; ByteArrayOutputStream br = null; try { URL requestUrl = new URL(url); String tempFilePath = tempFolder + requestUrl.getFile(); pptFile = new File(tempFilePath); if(!pptFile.getParentFile().exists()){ pptFile.getParentFile().mkdirs(); } // Code to download is = new BufferedInputStream(requestUrl.openStream()); br = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int n = 0; while (-1 != (n = is.read(buf))) { br.write(buf, 0, n); } byte[] response = br.toByteArray(); fos = new FileOutputStream(pptFile); fos.write(response); ppt = new HSLFSlideShow(new HSLFSlideShowImpl(tempFilePath)); Dimension pgsize = ppt.getPageSize(); String path = url.replaceFirst(hostUrl, ""); String destFormat = FileTypeHelper._s_defaultImgExtension; int lastDotIndex = path.lastIndexOf("."); if (ppt.getSlides() != null && !ppt.getSlides().isEmpty()) { imageFiles = new ArrayList<>(); List<HSLFSlide> slides = ppt.getSlides(); int i = 1; for (HSLFSlide slide: slides) { //防止中文乱码 for(HSLFShape shape : slide.getShapes()){ if(shape instanceof HSLFTextShape) { HSLFTextShape tsh = (HSLFTextShape)shape; for(HSLFTextParagraph p : tsh){ for(HSLFTextRun r : p){ r.setFontFamily("宋体"); } } } } BufferedImage img = new BufferedImage(pgsize.width,pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); graphics.setPaint(Color.white); graphics.clearRect(0, 0, pgsize.width, pgsize.height); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width,pgsize.height)); slide.draw(graphics); // save the output and upload String newPath =path.substring(0, lastDotIndex) + "(" + i + ")" + destFormat; File imageFile = new File( tempFolder+ "/" + newPath); fos = new FileOutputStream(imageFile); ImageIO.write(img, "jpeg", fos); GenericResult<String> token = getUptoken(newPath); if (token.getHr() == HResult.S_OK.getIndex() && token.getData() != null) { Response uploadResponse = uploadManager.put(tempFolder+ "/" + newPath, newPath, token.getData(), null, MimeTypeHelper.getMimeType(newPath), false); if (uploadResponse.isOK()) { imageFiles.add(hostUrl + newPath); imageFile.delete(); } } i++; } } } catch (Exception e) { logger.error("qiniu get ppt pages count error: ", e); } finally { try { if (is != null) is.close(); if (br != null) br.close(); if (fos != null) fos.close(); if (iStream != null) iStream.close(); if (rbc != null) rbc.close(); if(ppt != null) ppt.close(); if (pptFile != null && pptFile.exists()) pptFile.delete(); } catch (IOException e) { } } return imageFiles; }
0 0
- remote server ppt2003 to images
- put file from local to remote server
- how to remote connect to isa server 2000?
- How to configure SQL Server 2005 to allow remote connections
- How to configure SQL Server 2005 to allow remote connections
- Unable to connect to the remote server 问题
- Configure SQL Server 2005 to allow remote connections
- Backup Website Code、Database to Remote Server/Ftpserver Automatically
- Error when connecting to Windows Server 2003 using Remote Desktop
- How Do I Enable Remote Access To MySQL Database Server?
- C# How to get the system drive of remote server
- Changes to Remote Administration in Windows Server 2008
- How to enable remote connections in SQL Server 2008?
- 访问远程Redis服务。Connect to Remote Redis Server
- 10019---访问远程Redis服务。Connect to Remote Redis Server
- Can't connect to remote MySQL server with error 61
- 访问vm_cnetos 远程Redis服务。Connect to Remote Redis Server
- Exporting to Images
- transition transform body渐变色的填充方法
- 在Linux环境命令行中实现Wifi 连接的方法步骤详解
- 使用局部函数作为回调函数(未实现)
- 那么,请开始做好笔记
- Linux下的压缩&解压命令
- remote server ppt2003 to images
- transition transform 的rotate 和 translate的关系
- Redis进阶7-持久化
- 有n个人围成一圈,顺序排号。从第一个人开始报数(从1报到3),凡是报到3的人退出圈子,问最后留下的是原来第几号的那位
- 内存常见异常值
- jQuery学习之插件开发
- Redis进阶8之-集群
- 临时
- React全家桶之Redux(三)