Return-Path: X-Original-To: apmail-poi-user-archive@www.apache.org Delivered-To: apmail-poi-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 86CF810044 for ; Sun, 1 Feb 2015 07:19:33 +0000 (UTC) Received: (qmail 48558 invoked by uid 500); 1 Feb 2015 07:19:33 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 48443 invoked by uid 500); 1 Feb 2015 07:19:33 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 48427 invoked by uid 99); 1 Feb 2015 07:19:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Feb 2015 07:19:32 +0000 X-ASF-Spam-Status: No, hits=2.3 required=5.0 tests=SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of contact.txlabs@gmail.com does not designate 162.253.133.43 as permitted sender) Received: from [162.253.133.43] (HELO mwork.nabble.com) (162.253.133.43) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Feb 2015 07:19:27 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 37E1F1273219 for ; Sat, 31 Jan 2015 23:17:39 -0800 (PST) Date: Sun, 1 Feb 2015 00:17:37 -0700 (MST) From: atawfik To: user@poi.apache.org Message-ID: <1422775057165-5717802.post@n5.nabble.com> In-Reply-To: <54CD31C7.3080207@gmx.de> References: <1422718973251-5717798.post@n5.nabble.com> <54CD31C7.3080207@gmx.de> Subject: Re: How to import complex shaps Using POI XMLSlideShow MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Thanks Andi for your reply. My scenario is that i need to create presentations out of slides from various presentations. In a typical case, I create a new presentation and keep importing slides content to it using XMLSlideShow.createSlide().importContent. This method works fine in simple slides, but if i have slides like the second slide in the attached presentation, I get empty slides. I tested merging around 8 presentation files with around 450 slides. 100 of 450 slides were empty (25%). These empty slides are not coming from all presentations. Therefore, it is a serious problem for our application. I do not think the problem is drawing the slides because i successfully exported these slides into thumbnails without any problem. Below is the code to do that? public class MergeSlideTest { public static void main(String[] args) { File srcDir = new File("/usr/home/ameer/ test.pptx slides"); String[] files = {"test.pptx"}; for (String file : files) { try { FileInputStream fis = new FileInputStream(new File(srcDir,file)); XMLSlideShow srcSlideShow = new XMLSlideShow(fis); XSLFSlide[] slides = srcSlideShow.getSlides(); XMLSlideShow destSlideShow = new XMLSlideShow(); for (int i = 0; i < slides.length; i++) { try { takeSnapshot(slides[i]); destSlideShow.createSlide().importContent(slides[i]); } catch (Exception e) { System.out.println("Problem in exporting " + (i + 1) + " from " + file); e.printStackTrace(); } } fis.close(); FileOutputStream fos; try { fos = new FileOutputStream(new File("copy-"+file)); destSlideShow.write(fos); fos.close(); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } } } public static void takeSnapshot(XSLFSlide slide){ BufferedImage img = new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); //clear the drawing area graphics.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, 600, 600)); try { //render slide.draw(graphics); //save the output FileOutputStream out = new FileOutputStream(new File("slide-thumbnail.png")); javax.imageio.ImageIO.write(img, "png", out); out.close(); } catch (Exception e) { e.printStackTrace(); } } } -- View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-import-complex-shaps-Using-POI-XMLSlideShow-tp5717798p5717802.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org