https://bz.apache.org/bugzilla/show_bug.cgi?id=63290

--- Comment #2 from Axel Richter <axel.richter.pri...@web.de> ---
Used PowerPoint presentation, see attachment.
This only contains one text field containing one paragraph having the issue.
Used Code:

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.imageio.ImageIO;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import java.util.List;

public class PptToImageSimplest {
 public static void main(String args[]) throws Exception {
  FileInputStream in =new FileInputStream("PPT.pptx");
  XMLSlideShow ppt = new XMLSlideShow(in);
  //get the dimension of size of the slide
  Dimension pgsize = ppt.getPageSize();
  //get slides
  List<XSLFSlide> slides = ppt.getSlides();
  BufferedImage img = null;
  FileOutputStream out = null;
  for (int i = 0; i < slides.size(); i++) {
   img = new BufferedImage((int)Math.ceil(pgsize.width),
(int)Math.ceil(pgsize.height), BufferedImage.TYPE_INT_RGB);
   Graphics2D graphics = img.createGraphics();
   //clear the drawing area
   graphics.setPaint(Color.white);
   graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
   //render
   slides.get(i).draw(graphics);
   //creating an image file as output
   out = new FileOutputStream("ppt_image_" + i + ".png");
   ImageIO.write(img, "png", out);
   out.close();    
  }
 }
}


Problem:
Apache POI .draw(graphics) does not draw the first text run in text field
properly.
Reason:
The text field contains a paragraph which uses Default Run Properties in 
Paragraph Properties. The first text run has no Run Properties of it's own. XML
looks like:

<a:p>
 <a:pPr>
  <a:defRPr lang="de-DE" sz="4000" dirty="0" err="1" smtClean="0">
   <a:solidFill>
    <a:srgbClr val="FF0000"/>
   </a:solidFill>
  </a:defRPr>
 </a:pPr>
 <a:r>
  <a:t>DefaultRunProperties </a:t>
 </a:r>
 <a:r>
  <a:rPr lang="de-DE" sz="4000" dirty="0" err="1" smtClean="0">
   <a:solidFill>
    <a:srgbClr val="00FF00"/>
   </a:solidFill>
  </a:rPr>
  <a:t>ExplicitRunProperties</a:t>
 </a:r>
</a:p>

PowerPoint renders it so that first run inherits the defRP. But Apache POI does
not.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to