You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Lo...@log-net.com on 2012/08/08 02:48:03 UTC

pptx->png missing chart and symbols

I'm running into an issue rendering pptx slides to png images.  For the 
most part, it is working, but two issues are standing out:

1.  My chart disappears in the png.
2.  Certain special characters (alpha, beta) are being rendered as boxes 
(guessing this is a font/Graphics2D issue).

Just looking for any direction on this.  I'm a little lost.  Is it 
Graphics2D; POI; ImageIO?

My code:

           img = new BufferedImage(width, height, BufferedImage.
TYPE_INT_RGB);
           Graphics2D graphics = img.createGraphics();
           graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
RenderingHints.VALUE_ANTIALIAS_ON);
           graphics.setRenderingHint(RenderingHints.KEY_RENDERING, 
RenderingHints.VALUE_RENDER_QUALITY);
           graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
           graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
           graphics.setPaint(Color.white);
           graphics.fill(new Rectangle2D.Float(0, 0, width, height));
           graphics.scale((double)width/pgsize.width, (double
)height/pgsize.height);

           slide.draw(graphics);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write( img, "png", baos );

I'm on POI 3.8 under jdk 1.5.

Thanks,
Lou

Re: pptx->png missing chart and symbols

Posted by Yegor Kozlov <ye...@dinom.ru>.
>
> For the chart stuff, if you point me in the right direction, I'll try to
> take a crack at the code.
>

believe me, it won't be a easy task :)
For a start you can take a sample .pptx file with a chart, unzip it
and examine the contents. You want to look at slide.xml and its
relationships. Start with a simple type (bar or pie chart) and see how
the drawing area changes with the data, what happens when you change
the legend, color, etc.

To understand what all those xml tags mean you will need the OOXML
spec which can be downloaded from
http://www.ecma-international.org/publications/standards/Ecma-376.htm

I used this reverse-engineering based approach when I wrote the
pptx->png converter.

Regards,
Yegor

> Thanks,
> Lou
>
> Yegor Kozlov <ye...@dinom.ru> wrote on 2012-08-08 02:44:30 AM:
>
>> Yegor Kozlov <ye...@dinom.ru>
>> 2012-08-08 02:44 AM
>>
>> Please respond to
>> "POI Users List" <us...@poi.apache.org>
>>
>> To
>>
>> POI Users List <us...@poi.apache.org>,
>>
>> cc
>>
>> Subject
>>
>> Re: pptx->png missing chart and symbols
>>
>> >
>> > 1.  My chart disappears in the png.
>>
>> rendering charts is not yet supported
>>
>> > 2.  Certain special characters (alpha, beta) are being rendered as
> boxes
>> > (guessing this is a font/Graphics2D issue).
>> >
>>
>> What font are you using for the special characters? Java can render
>> only unicode fonts. If you are using Wingdings or Symbol then try to
>> find equivalents in Arial Unicode MS and make sure this font is
>> avaliable to Java.
>>
>> Yegor
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>

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


Re: pptx->png missing chart and symbols

Posted by Lo...@log-net.com.
Just to clarify, the slides are correct when I copy/merge.  This issue is 
only with the PNG generation.

For the chart, I asked the user to convert them to images.  We'll see how 
that flies.

For the fonts, I took your rec and asked them to switch the symbols to 
Arial Unicode.  That seems to work OK.

For the chart stuff, if you point me in the right direction, I'll try to 
take a crack at the code.

Thanks,
Lou

Yegor Kozlov <ye...@dinom.ru> wrote on 2012-08-08 02:44:30 AM:

> Yegor Kozlov <ye...@dinom.ru> 
> 2012-08-08 02:44 AM
> 
> Please respond to
> "POI Users List" <us...@poi.apache.org>
> 
> To
> 
> POI Users List <us...@poi.apache.org>, 
> 
> cc
> 
> Subject
> 
> Re: pptx->png missing chart and symbols
> 
> >
> > 1.  My chart disappears in the png.
> 
> rendering charts is not yet supported
> 
> > 2.  Certain special characters (alpha, beta) are being rendered as 
boxes
> > (guessing this is a font/Graphics2D issue).
> >
> 
> What font are you using for the special characters? Java can render
> only unicode fonts. If you are using Wingdings or Symbol then try to
> find equivalents in Arial Unicode MS and make sure this font is
> avaliable to Java.
> 
> Yegor
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 

Re: pptx->png missing chart and symbols

Posted by Yegor Kozlov <ye...@dinom.ru>.
>
> 1.  My chart disappears in the png.

rendering charts is not yet supported

> 2.  Certain special characters (alpha, beta) are being rendered as boxes
> (guessing this is a font/Graphics2D issue).
>

What font are you using for the special characters? Java can render
only unicode fonts. If you are using Wingdings or Symbol then try to
find equivalents in Arial Unicode MS and make sure this font is
avaliable to Java.

Yegor

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