(java) Background drawing problems


#1

I’m using the Java evaluation version of Aspose.PowerPoint just to get an idea of its capabilities. I’ve used it with Batik to generate .jpg files from various slides, but the backgrounds don’t seem to be generated accurately. My sample program reads in a test .ppt file, and then converts a slide to an image, but the background rarely seems to be what it is in the original presentation. Solid colors are often rendered as white, and only parts of objects in the background of the style appear. Do I have to do something involving the slide master first, perhaps? I can provide examples if needed. Thanks.


#2

Yes, please provide examples. If it’s a problem of Aspose.PowerPoint we will fix it.
You can also try to open svg file with IE + Adobe svg plugin to be sure.
But most of problems usually because of Batik limitations.
We started development of our own thumbnail creator. Probably it will be available
at the end of March. So all features Java version will be the same as for .Net.


#3

The viewer displays the .svg file the same as the converted .jpg… I’ve attached a .zip file containing the source .ppt, the .svg generated from the only slide in the presentation, and the .jpg that I’ve generated with Batik. Since this is a test case, all of the code is located in the main() method of a simple Java application. Here’s the contents of that method, along with the necessary imports:

import java.awt.BorderLayout;
import java.awt.Color;
import java.io.;
import java.util.Date;
import javax.swing.
;

import com.aspose.powerpoint.;
import org.apache.batik.apps.rasterizer.
;

public static void main(String[] args)
{
try
{
File file = new File(“test.ppt”);
Presentation presentation = new Presentation(new FileInputStream(file));
Slides slides = presentation.getSlides();
if(slides.size() > 0)
{
Slide slide = slides.get(0);

// create the filenames
File svgFile = new File(“slide.svg”);
File jpgFile = new File(“slide.jpg”);

// save the slide to a SVG
slide.saveToSVG(new FileOutputStream(svgFile));

// convert the SVG to a JPG
SVGConverterFileSource source = new SVGConverterFileSource(svgFile);
SVGConverter converter = new SVGConverter();
converter.setHeight((float)800.0);
converter.setSources(new String[]{svgFile.getPath()});
converter.setQuality((float)0.99);

converter.setDestinationType(DestinationType.JPEG);
converter.setDst(jpgFile);
converter.execute();

// create a simple dialog to display the converted JPG
JDialog imageDisplay = new JDialog();
ImageIcon image = new ImageIcon(jpgFile.getPath());
JLabel imageLabel = new JLabel(image);
imageDisplay.getContentPane().setLayout(new BorderLayout());
imageDisplay.getContentPane().add(imageLabel, BorderLayout.NORTH);
imageDisplay.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
imageDisplay.pack();
imageDisplay.setLocationRelativeTo(null);
imageDisplay.setResizable(false);
imageDisplay.setVisible(true);
}
}
catch(Exception e)
{
System.out.println(“Caught exception:”);
e.printStackTrace();
}
}


#4

Yes, gradients are not implemented yet in Java version.
We will add it on the next week.


#5

Good to know. However, a slide with a simple, solid background color renders with a white background as well. Does that fall in with the gradients, or should that work?


#6

Solid background should work.


#7

Even when I try to set a plain solid-color background, it doesn’t seem to be represented in the .svg file. I’ve attached another example .zip, generated using the same code above.