We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Slide 17.1 is not backword compatible

Hi,


I am an old customer of Aspose-Slide I am using aspose.slides-8.0.0.jar version in my Application to create video an image presentation. With that version I have an issue with Aspose and I logged a ticked for that https://www.aspose.com/community/forums/490235/thumbnail-on-windows-media-player/showthread.aspx on your forum and I got information that this issue has been fixed now.

And I am trying to test this with your latest release aspose-slides-17.1-jdk16.jar but my code is not working and giving following Error:

java.lang.NoClassDefFoundError: com/aspose/slides/SlidesEx
Inside method of getStackTraceAsString method
Hiding Busy Indicator ***************************************
at org.ism.mvp.view.controller.ISMPPTController$6.call(ISMPPTController.java:514)
at org.ism.mvp.view.controller.ISMPPTController$6.call(ISMPPTController.java:449)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1259)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.aspose.slides.SlidesEx
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
… 5 more


Please suggest the correct version of Aspose for this issue by which I need not to go for change in may code.




Hi Rahul,


I have observed your comments. Can you please share environment details with us, also please source code so that we can further investigate and to resolve the issue.

Best Regards,

Hi,

Thanks for your reply. I am on windows-10, jdk1.7.0_79, JavaFx 2.2.79-b14,
And the source code is:

I am generating Video and Image presentation.

and the main file of code is:

package org.mvp.powerpoint;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.imageio.ImageIO;

import com.aspose.slides.AudioVolumeModeEx;
import com.aspose.slides.AutoShapeEx;
import com.aspose.slides.BackgroundTypeEx;
import com.aspose.slides.ControlEx;
import com.aspose.slides.ControlTypeEx;
import com.aspose.slides.FillTypeEx;
import com.aspose.slides.FontsLoader;
import com.aspose.slides.ImageEx;
import com.aspose.slides.License;
import com.aspose.slides.LoadFormat;
import com.aspose.slides.LoadOptions;
import com.aspose.slides.NullableBool;
import com.aspose.slides.ParagraphEx;
import com.aspose.slides.PictureFillModeEx;
import com.aspose.slides.PictureFrameEx;
import com.aspose.slides.PresentationEx;
import com.aspose.slides.ShapeTypeEx;
import com.aspose.slides.SlideEx;
import com.aspose.slides.SlidesEx;
import com.aspose.slides.VideoEx;
import com.aspose.slides.VideoFrameEx;
import com.aspose.slides.VideoPlayModePresetEx;
import java.awt.Color;
import java.net.URL;

public class PresentationCreation implements CreatePresentationInterface {

private static PresentationEx pptMakeInitFast;
PresentationEx ppt;
int imageIndex = 1;
int videoIndex = 1;
IPPTEvents m_Notify = null;
private boolean isEmbedded;
private String linkType;

public static void loadLicense(String licenseFilePath) throws Throwable {
File randomPPTPath=new File(System.getProperty(“java.io.tmpdir”)+File.separator+“temp.pptx”);
URL url = new URL(“file:” + licenseFilePath);
File licenceFile = new File(url.toURI());
//Create a stream object containing the license file
FileInputStream fstream = new FileInputStream(licenceFile);
//Instantiate the License class
License license = new License();
//Set the license through the stream object
license.setLicense(fstream);
FontsLoader.loadExternalFonts(new String[]{"/Library/Fonts", “/Library/Fonts/Microsoft”});
// Anonymous Object created to save starting time in further Object creation.
pptMakeInitFast=new PresentationEx();
pptMakeInitFast.write(randomPPTPath.getAbsolutePath());
randomPPTPath.delete();
}

public void addListener(IPPTEvents listener) {
m_Notify = listener;
}

public int createTemplate(String strTemplatePath, String strImagePath, String[] arrError) {
try {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Creating power point template.”);
} else {
return -1;
}

PresentationEx pres = new PresentationEx();
pres.getSlides().get_Item(0).getBackground().setType(BackgroundTypeEx.OwnBackground);
pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(FillTypeEx.Picture);
pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillModeEx.Stretch);

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Adding Image to template.”);
} else {
return -1;
}

BufferedImage image = ImageIO.read(new File(strImagePath));
ImageEx imgx = pres.getImages().addImage(image);
pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Writing template to disk.”);
} else {
return -1;
}

pres.write(strTemplatePath);

arrError[0] = “Template successfully saved.”;
return 0;
} catch (Exception e) {
if (m_Notify != null) {
m_Notify.LogInfo(LogType.error, "PPT Creation createImageSlide Error : " + e.getMessage());
}
arrError[0] = e.getMessage();
return 1;
} catch (Error e) {
if (m_Notify != null) {
m_Notify.LogInfo(LogType.error, "PPT Creation createImageSlide Error : " + e.getMessage());
}
arrError[0] = e.getMessage();
return 1;
}
}

public String createPresentation(boolean isEmbedded, String linkType, List vid, List thumb,
List img, String pathPpt, String temp) {
try {
this.isEmbedded = isEmbedded;
this.linkType = linkType;
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Creating PowerPoint ppt.”);
m_Notify.LogInfo(LogType.information, "Creating PowerPoint ppt " + pathPpt);
} else {
return “Abort”;
}

List vidList = new ArrayList();
for (String s : vid) {
vidList.add(new File(s));
}
List thumbList = new ArrayList();
for (String s : thumb) {
thumbList.add(new File(s));
}
List imgList = new ArrayList();
for (String s : img) {
imgList.add(new File(s));
}

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Loading default font.”);
m_Notify.LogInfo(LogType.information, “Loading default font.”);
} else {
return “Abort”;
}

// LoadOptions lo = new LoadOptions(LoadFormat.Auto);
// lo.setDefaultRegularFont(“Arial”);
// lo.setDefaultAsianFont(“Arial”);
// lo.setDefaultSymbolFont(“Arial”);
if (temp == null) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Initializing slides.”);
m_Notify.LogInfo(LogType.information, “Initializing slides.”);
} else {
return “Abort”;
}
ppt = new PresentationEx();
} else {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Creating main slide from template.”);
m_Notify.LogInfo(LogType.information, “Creating main slide from template.”);
} else {
return “Abort”;
}
File template = new File(temp);
ppt = new PresentationEx(template.getAbsolutePath());
}

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Adding videos.”);
m_Notify.LogInfo(LogType.information, “Adding videos started.”);
} else {
return “Abort”;
}


int noOfImageSlides;
Iterator iterateVid = vidList.iterator();
Iterator iterateThumb = thumbList.iterator();
if (thumbList.size() > 0) {
while (iterateVid.hasNext() && iterateThumb.hasNext()) {
if (m_Notify != null) {
m_Notify.SetStatus("Adding video slide " + String.valueOf(videoIndex) + " of " + String.valueOf(vidList.size()));
m_Notify.LogInfo(LogType.information, "Adding video slide " + String.valueOf(videoIndex) + " of " + String.valueOf(vidList.size()));
}
createVideoSlide(iterateVid.next(), iterateThumb.next());
videoIndex++;
}
}

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Adding Images.”);
m_Notify.LogInfo(LogType.information, “Adding images started.”);
} else {
return “Abort”;
}

int iImageCount = imgList.size();
noOfImageSlides = (iImageCount / 4 + ((iImageCount % 4) == 0 ? 0 : 1));

for (int iSlideIndex = 0; iSlideIndex < noOfImageSlides; iSlideIndex++) {
int baseIndex = 0;
int iImageIndex = iSlideIndex * 4;
baseIndex = iImageIndex + 1;
List slideImages = new ArrayList();
for (; iImageIndex < iImageCount; iImageIndex++) {
slideImages.add(imgList.get(iImageIndex));
}

// Create slide with images
createImageSlide(slideImages, baseIndex, iImageCount);
}

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus(“Saving presentation on disk.”);
m_Notify.LogInfo(LogType.information, “Saving presentation on disk.”);
} else {
return “Abort”;
}
ppt.getSlides().removeAt(0);
ppt.write(pathPpt);
return null;
} catch (Exception e) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.LogInfo(LogType.error, "PPT Creation createImageSlide Error : " + e.getMessage());
} else {
return “Abort”;
}
return e.getMessage();
}
}

public float[] maintainAspectRatioOfImage(float imgWidth, float imgHgt, float maxWdth, float maxHgt) {
float[] returnHgtWdt = new float[2];
if (imgWidth > maxWdth) {
float factorOfWidth = (imgWidth - maxWdth) / imgWidth;
float encreaseHeight = imgHgt - (factorOfWidth * imgHgt);

if (encreaseHeight > maxHgt) {
return maintainAspectRatioOfImage(maxWdth, encreaseHeight, maxWdth, maxHgt);
}

returnHgtWdt[0] = maxWdth;
returnHgtWdt[1] = encreaseHeight;
} else if (imgHgt > maxHgt) {
float factoreHeight = (imgHgt - maxHgt) / imgHgt;
float enceraseWidth = imgWidth - (factoreHeight * imgWidth);
if (enceraseWidth > maxWdth) {
return maintainAspectRatioOfImage(enceraseWidth, maxHgt, maxWdth, maxHgt);
}

returnHgtWdt[0] = enceraseWidth;
returnHgtWdt[1] = maxHgt;
} else {
returnHgtWdt[0] = imgWidth;
returnHgtWdt[1] = imgHgt;
}
return returnHgtWdt;
}

private int createImageSlide(List listImages, int iImageIndex, int iTotalImages) {
try {
SlidesEx slide = ppt.getSlides();
int slideno = slide.addClone(ppt.getSlides().get_Item(0));
SlideEx sld = ppt.getSlides().get_Item(slideno);
int posImages = 0;

float width = (float) ppt.getSlideSize().getSize().getWidth() / 2 - 30;
float height = (float) ppt.getSlideSize().getSize().getHeight() / 2 - 40;

float[][] positionImage = new float[4][];

// Positions for 4 images
positionImage[0] = new float[]{20, 20, width, height};
positionImage[1] = new float[]{40 + width, 20, width, height};
positionImage[2] = new float[]{20, 40 + height, width, height};
positionImage[3] = new float[]{40 + width, 40 + height, width, height};


for (File singleImage : listImages) {
// Creating a Buffered Image object to hold the image file
BufferedImage image = null;

try {
image = ImageIO.read(singleImage);
} catch (IOException e) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.LogInfo(LogType.error, "PPT Creation createImageSlide Error : " + e.getMessage());
} else {
return -1;
}
}

if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.SetStatus("Adding Image " + String.valueOf(iImageIndex) + " of " + String.valueOf(iTotalImages));
m_Notify.LogInfo(LogType.information, "Adding Image " + String.valueOf(iImageIndex) + " of " + String.valueOf(iTotalImages));
} else {
return -1;
}

ImageEx imgx = ppt.getImages().addImage(image);

// Add Picture Frame with height and width equivalent of Picture
int iPictureIndex = sld.getShapes().addPictureFrame(ShapeTypeEx.Rectangle,
positionImage[posImages][0], positionImage[posImages][1],
positionImage[posImages][2], positionImage[posImages][3],
imgx);

PictureFrameEx picFrame = (PictureFrameEx) sld.getShapes().get_Item(iPictureIndex);

float[] arrDimensions = maintainAspectRatioOfImage(imgx.getWidth(), imgx.getHeight(), width, height);
picFrame.setWidth(arrDimensions[0]);
picFrame.setHeight(arrDimensions[1]);



float fTextY = picFrame.getY() + picFrame.getHeight() + 2.0f;
float fTextX = picFrame.getX() + picFrame.getWidth() / 2.0f - 50.0f;

// Add an AutoShape of Rectangle type
int iTextIndex = sld.getShapes().addAutoShape(ShapeTypeEx.Rectangle,
fTextX,
fTextY,
10,
10);


AutoShapeEx ashp = (AutoShapeEx) sld.getShapes().get_Item(iTextIndex);
ashp.setUseBackgroundFill(false);//getFillFormat().setFillType(1);
// Add TextFrame to the Rectangle
ashp.getLineFormat().getFillFormat().setFillType(FillTypeEx.NoFill);
ashp.getFillFormat().setFillType(FillTypeEx.NoFill);
ashp.addTextFrame(“Image-” + iImageIndex);
ParagraphEx imageNumber = ashp.getTextFrame().getParagraphs().get_Item(0);
imageNumber.getPortions().get_Item(0).getFillFormat().setFillType(FillTypeEx.Solid);
imageNumber.getPortions().get_Item(0).getFillFormat().getSolidFillColor().setColor(Color.BLACK);
imageNumber.getPortions().get_Item(0).setFontBold(NullableBool.True);
ashp.setWidth(100);
ashp.setHeight(20);
iImageIndex++;
posImages++;
}
} catch (Exception ex) {
if (m_Notify != null) {
m_Notify.LogInfo(LogType.error, "PPT Creation createImageSlide Error : " + ex.getMessage());
}
}
return 0;
}

private boolean createVideoSlide(File vidiLink, File thumbLink) throws IOException {
FileInputStream videoStream = null;
FileInputStream thumbStream = null;
VideoFrameEx vf = null;
try {
long fileSizeinBytes=vidiLink.length();
long fileSizeinMB=fileSizeinBytes/(1024*1024);
m_Notify.LogInfo(LogType.information, “Adding Video “+videoIndex +” of size “+fileSizeinMB+” MB”);
SlidesEx slide = ppt.getSlides();
int slideno = slide.addClone(ppt.getSlides().get_Item(0));
SlideEx sld = ppt.getSlides().get_Item(slideno);
float AR = (float) (1920.0 / 1080.0);
if (isEmbedded) {
// Add Video Frame
vf = sld.getShapes().addVideoFrame(50, 75, 350 * AR, 350, vidiLink.getAbsolutePath());
videoStream = new FileInputStream(vidiLink.getAbsolutePath());
VideoEx vid = ppt.getVideos().addVideo(videoStream); // adding VideoEx from stream
vf.setEmbeddedVideo(vid);

} else {
if (linkType.equals(“WMP”)) {
ControlEx control = sld.getControls().addControl(ControlTypeEx.WindowsMediaPlayer, 50, 75, 350 * AR, 350);
// Aspose 8.0 changed “url” to “URL”.
control.getProperties().set_Item(“URL”, vidiLink.getName());
} else if (linkType.equals(“DEFAULT”)) {
vf = sld.getShapes().addVideoFrame(50, 75, 350 * AR, 350, vidiLink.getName());
}

}

if (vf != null) {
// Set Play Mode and Volume of the Video
vf.setPlayMode(VideoPlayModePresetEx.Auto);
vf.setVolume(AudioVolumeModeEx.Loud);
// Creating a Buffered Image object to hold the image file
}
BufferedImage image = null;
try {
thumbStream = new FileInputStream(thumbLink);
image = ImageIO.read(thumbStream);
} catch (IOException e) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.LogInfo(LogType.error, "PPT Creation createVideoSlide Error : " + e.getMessage());
} else {
return false;
}

}
if (image == null) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.LogInfo(LogType.error, “PPT Creation createVideoSlide , Thumbnail " + thumbLink.getPath() + " not found for video” + vidiLink.getPath());
} else {
return false;
}

} else {
// add thumbnail for video
ImageEx imgx = ppt.getImages().addImage(image);
if (vf != null) {
vf.setImage(imgx);

}
}
// Add an AutoShape of Rectangle type
int idx = sld.getShapes().addAutoShape(ShapeTypeEx.Rectangle, 300, 450, 50, 100);
AutoShapeEx ashp = (AutoShapeEx) sld.getShapes().get_Item(idx);
ashp.setUseBackgroundFill(false);//getFillFormat().setFillType(1);
// Add TextFrame to the Rectangle
ashp.getLineFormat().getFillFormat().setFillType(FillTypeEx.NoFill);
ashp.getFillFormat().setFillType(FillTypeEx.NoFill);
ashp.addTextFrame(“Video-” + videoIndex);
ParagraphEx imageNumber = ashp.getTextFrame().getParagraphs().get_Item(0);
imageNumber.getPortions().get_Item(0).getFillFormat().setFillType(FillTypeEx.Solid);
imageNumber.getPortions().get_Item(0).getFillFormat().getSolidFillColor().setColor(Color.BLACK);
imageNumber.getPortions().get_Item(0).setFontBold(NullableBool.True);
// Add TextFrame to the Rectangle
ashp.setWidth(100);
ashp.setHeight(20);
return true;
} catch (IOException ex) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.LogInfo(LogType.error, "PPT Creation createVideoSlide Error : " + ex.getMessage());
} else {
return false;
}
} catch (Exception ex) {
if (m_Notify != null && m_Notify.isRunning()) {
m_Notify.LogInfo(LogType.error, "PPT Creation createVideoSlide Error : " + ex.getMessage());
} else {
return false;
}
} finally {
if (videoStream != null) {
videoStream.close();
}
if (thumbStream != null) {
thumbStream.close();
}

}
return false;
}
}

Hi Rahul,

I have observed that you are using our old API still that is obsolete now. The latest version available to date is Aspose.Slides for Java 17.1.0 which is completely new API and has single class interfaces for both PPT and PPTX presentations as against one you are using. I suggest you to please shift to latest version for continued support. As far as your requirement for setting image to media player ActiveX control in PowerPoint presentation is concerned, actually there is no such property for setting a substitute image for WMP control in PowerPoint. This is not a bug but limitation on PowerPoint and WMP end. Under these lines the issue was marked resolved. Please observe the attached snapshot for reference. I hope this will be helpful. Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassi,

Thanks for reply,

We have purchased license for Aspose-Slide 8.0.0.0 version,will this license work for new API?
I has downloaded slides-java-Examples and trying to run this but it is giving compile time error. I am trying to run this on jdk1.7.0_79.




Hi Rahul,


I have observed your comments. I like to inforthat as per Aspose policy, you can avail the product release versions till one year from purchase date. I suggest you to renew your subscription to avail latest product release.

Best Regards,