You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by fridayeva <yl...@smarttech.com> on 2018/03/06 02:52:33 UTC

Background color missing when converting Powerpoint to PNG

Hi,

I am using 3.17, trying to convert a PPT file to PNG, but some page preview
image is missing background colors while others work fine. Similar things
happens for PPTX files. The image background theme is black but it is
supposed to be blue.

My code to generate page preview is :

public BufferedImage pdPageToBufferedImage(int pageNumber, int height, int
width) {
        BufferedImage img = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = img.createGraphics();
//here I give examples for PPT files, for PPTX it is XSLFSlide instead of
HSLFSlide, rest code is same.
        HSLFSlide slide = presentation.getSlides().get(pageNumber);
        graphics.setPaint(Color.white);
        graphics.fill(new Rectangle2D.Float(0, 0, width, height));
        slide.draw(graphics);
        return img;
    }


Also, I have attached the two comparison images to show the difference. Left
is png view, and right is powerpoint view.

<http://apache-poi.1045710.n5.nabble.com/file/t340536/diff1.png> 



<http://apache-poi.1045710.n5.nabble.com/file/t340536/diff3.png> 

Thanks.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Background color missing when converting Powerpoint to PNG

Posted by Andreas Beeker <ki...@apache.org>.
Hi,

I think those glitches are related to the theme support which I haven't put too much effort in yet.
The themes.pptx in our testdata repo shows also similar color issues.

If you like, you could start from the DrawPaint class and check where it goes wrong.
Otherwise I'll have a look at your files, if you upload them to a bugzilla entry,
but I can't promise you immediately fixes.

Andi


On 3/6/18 3:52 AM, fridayeva wrote:
> Hi,
>
> I am using 3.17, trying to convert a PPT file to PNG, but some page preview
> image is missing background colors while others work fine. Similar things
> happens for PPTX files. The image background theme is black but it is
> supposed to be blue.
>
> My code to generate page preview is :
>
> public BufferedImage pdPageToBufferedImage(int pageNumber, int height, int
> width) {
>         BufferedImage img = new BufferedImage(width, height,
> BufferedImage.TYPE_INT_RGB);
>         Graphics2D graphics = img.createGraphics();
> //here I give examples for PPT files, for PPTX it is XSLFSlide instead of
> HSLFSlide, rest code is same.
>         HSLFSlide slide = presentation.getSlides().get(pageNumber);
>         graphics.setPaint(Color.white);
>         graphics.fill(new Rectangle2D.Float(0, 0, width, height));
>         slide.draw(graphics);
>         return img;
>     }
>
>
> Also, I have attached the two comparison images to show the difference. Left
> is png view, and right is powerpoint view.
>
> <http://apache-poi.1045710.n5.nabble.com/file/t340536/diff1.png> 
>
>
>
> <http://apache-poi.1045710.n5.nabble.com/file/t340536/diff3.png> 
>
> Thanks.
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>