[Bug 63460] New: I have created pptx and ppt converter to images using apache poi but while converting some file i have an exception after two or three converts.

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 63460] New: I have created pptx and ppt converter to images using apache poi but while converting some file i have an exception after two or three converts.

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

            Bug ID: 63460
           Summary: I have created pptx and ppt converter to images using
                    apache poi but while converting some file i have an
                    exception after two or three converts.
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: critical
          Priority: P2
         Component: SL Common
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Created attachment 36596
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36596&action=edit
Converted gradient slide [greyed]

//    Exception in thread "main" java.lang.IllegalArgumentException: Color
//    parameter outside of expected range: Red

//    Main converter from both pptx and ppt

import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlide;

import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class Application {


    public static void main(String[] args) throws Exception {

        System.out.println("working");

        String directory = System.getProperty("user.home") + "/Desktop/";

        //creating an empty presentation
        File file=new File(directory + "test6.pptx");
        String fileName = file.getName();
        // Identify the file whether it is ppt or pptx
        String extension = fileName.substring(fileName.lastIndexOf(".") + 1);

        FileInputStream inputStream = new FileInputStream(directory +
fileName);

        if (extension.equals("pptx")) {


            XMLSlideShow pptx = new XMLSlideShow(inputStream);

            //getting the dimensions and size of the slide
            Dimension pgsize = pptx.getPageSize();
            java.util.List<XSLFSlide> pptxSlide =
Arrays.asList(pptx.getSlides());

            for (int i = 0; i < pptxSlide.size(); i++) {
                BufferedImage img = new BufferedImage(pgsize.width,
pgsize.height,BufferedImage.TYPE_INT_RGB);

                Graphics2D graphics = createImage(img, pgsize);
                //render
                pptxSlide.get(i).draw(graphics);
                graphics.setComposite(AlphaComposite.DstOver);
                graphics.setPaint(Color.WHITE);

                //creating an image file as output
                imageFile(i, img);


                graphics.dispose();

            }


        }else if(extension.equals("ppt")){


            SlideShow ppt = new SlideShow(inputStream);

            //getting the dimensions and size of the slide
            Dimension pgsize = ppt.getPageSize();
            List<Slide> slide = Arrays.asList(ppt.getSlides());

            for (int i = 0; i < slide.size(); i++) {
                BufferedImage img = new BufferedImage(pgsize.width,
pgsize.height,BufferedImage.TYPE_INT_RGB);

                //render
                slide.get(i).draw(createImage(img, pgsize));


                //creating an image file as output
                imageFile(i, img);
            }
        }else {
            throw new Exception("Not compatible type ");
        }
    }

    private static void imageFile(int i, BufferedImage img) throws IOException
{
        FileOutputStream out = new FileOutputStream("ppt_image_" + i + ".png");
        javax.imageio.ImageIO.write(img, "png", out);
        System.out.println("Image successfully created");
        out.close();
    }


    private static Graphics2D createImage(BufferedImage img, Dimension pgsize){
        Graphics2D graphics = img.createGraphics();

        //clear the drawing area
        graphics.setPaint(Color.white);
        graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width,
pgsize.height));
        // default rendering options
        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.setComposite(AlphaComposite.DstOver);


        return graphics;
    }
}

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63460] I have created pptx and ppt converter to images using apache poi but while converting some file i have an exception after two or three converts.

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

--- Comment #1 from Andreas Beeker <[hidden email]> ---
For testing I'll use the PPTX2PNG class [1], which is basically the same as
your code. As we haven't got that error on our huge test corpus (which is only
used before we do a release), I guess the color reference to "Red" was
generated by a custom tool, right? (i.e. do you know the origin of the .pptx
file?)

[1]
https://svn.apache.org/repos/asf/poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63460] I have created pptx and ppt converter to images using apache poi but while converting some file i have an exception after two or three converts.

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

Andreas Beeker <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Andreas Beeker <[hidden email]> ---
I've just realized, that you've uploaded the .png file ... but I've asked for
the .pptx on stackoverflow [2]. I can generate the .png myself - please upload
the .pptx.


[2]
https://stackoverflow.com/questions/56221004/gradient-color-issue-when-converting-from-pptx-to-images-apache-poi

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63460] I have created pptx and ppt converter to images using apache poi but while converting some file i have an exception after two or three converts.

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

--- Comment #3 from Alloy <[hidden email]> ---
Created attachment 36598
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36598&action=edit
pptx file that i have used

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63460] I have created pptx and ppt converter to images using apache poi but while converting some file i have an exception after two or three converts.

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

--- Comment #4 from Andreas Beeker <[hidden email]> ---
Your provided file is not throwing the error. I'm using the trunk version of
POI, which should be similar to the latest released stable version. I've tested
with the PPTX2PNG class and also with the code you've provided ... in your
case, I would also use PPTX2PNG, because your code produces white images.
I guess the failing file is "test6.pptx" instead of "test7.pptx".

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63460] Exception thrown when converting powerpoint files to images

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

Dominik Stadler <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|I have created pptx and ppt |Exception thrown when
                   |converter to images using   |converting powerpoint files
                   |apache poi but while        |to images
                   |converting some file i have |
                   |an exception after two or   |
                   |three converts.             |

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63460] Exception thrown when converting powerpoint files to images

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63460

Dominik Stadler <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #5 from Dominik Stadler <[hidden email]> ---
We could not reproduce this, so I am closing this for now, please reopen with
some more information if this still happens with the latest version Apache POI
5.0.0.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]