Evalution version - Aspose Live Support

Hi Sarfraz,

I have downloaded the Aspose.Slides 1.6.16.0 form the link which you sent in your last mail. Even I am not able to run my sample program.

Below is the exception I am getting when I run my test program.

java.lang.UnsupportedClassVersionError: com/deluxe/spti/powerpointer/Asposepowerpoint (Unsupported major.minor version 48.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:703)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:320)
at java.net.URLClassLoader.access$400(URLClassLoader.java:93)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:239)
at java.lang.ClassLoader.loadClass(ClassLoader.java:516)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:460)
at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
Exception in thread "main"

I am sending my source code as attachment, kindly go through it.

Please help me how to resolve this error.

Thanks & Regards,
Swamy


From: `Salman Sarfraz
Sent: Wednesday, April 18, 2007 12:20 PM
To: Swamy KPN
Cc: Alexey Zhilin; Ben Li; Danny Cooper
Subject: Evaluation version - Aspose Live Support

Dear Swamy,

Thanks for considering Aspose.

It’s strange. Aspose.Slides for Java is supported on JRE 1.4 and 1.5 (5.0). Please try this one and let me know:

Have a good time.

Many Thanks & Kind Regards,

Yours Truly,

Salman Sarfraz
Team Leader,
Aspose Service Team
Aspose - The .NET and Java Component Publisher


Name: Swamy / Swamy(Anonymous)
Email: swamy_kpn@mindtree.com

Subject: Evalution version
Message:

I have downloaded Aspose.Slides evaluation software which is support for jdk1.5.
Could you please give me a link where can i download Aspose.Slides software which basically support jdk1.4 version.

Thanks& Regards,
Swamy

Dear Swamy,

I don’t know what is causing you this problem and all the code looks fine and runs well except this line

/Removing the first slide of the presentation which is always added by Aspose.Slides by default while creating the presentation

pres.getSlides().removeAt(0);

would be more precise, if you change it like this one.

pres.getSlides().remove(pres.getSlideByPosition(1)));

The reason being is that you could remove master slide mistakenly if there is any.

Hi Shakeel Faiz,

Thnaks for the solution.Now it's working fine.

i have rquirement is like to display the text in to different fonts.

For this

I have searched in Wiki and i got an example code, in that code for getting the existing font they mentione below code sinppet and finally adding the FontEntity in to Presentaion class.

Presentation pres = new Presentation();

//Get the existing font
FontEntity fntEnt = pres.Fonts[0];

//Add new Font-->Times New Roman into Fonts collection

FontEntity fntEntNew = new FontEntity(pres, fntEnt);

fntEntNew.FontName = "Times New Roman";

int fntEntNewIdx = pres.Fonts.Add(fntEntNew);

But i saw the Apose.Slides JAVA API , in Presentation class there is no method called Fonts[arguments].

For adding text i am using Rectangle.addTextFrame("some text") method.

I have tried with below code but i got stuck up because of how to add FontEntity object in to presentation class. Please see my code below.

Fonts font = pres.getFonts();

FontEntity fe= font.get(0);

fe.setFontName("Times New Roman");

Kindly provide me a solution on this.

Note : I have downloded latest Evalution software i.e Aspose.Slides 1.6.16.0.

Thanks & Regards,

Swamy

Dear Suvraj,

Thank you for considering Aspose.Slides for Java.

I have attached the code and output presentation for you which shows how to add text with different fonts in textframe using Java Aspose.Slides.

Here is the code

import java.io.File;
import java.io.FileOutputStream;
import com.aspose.slides.*;

public class JProgram {
    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            JProgram jprog = new JProgram();
            jprog.TextWithFonts();
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }

    private void TextWithFonts() {
        try {
            Presentation pres = new Presentation();

            //Get the existing font which is added by default
            FontEntity fntEnt = pres.getFonts().get(0);

            //Add new Font-->Times New Roman
            FontEntity fntEntNew = new FontEntity(pres, fntEnt);
            fntEntNew.setFontName("Times New Roman");
            int FontTimesIdx = pres.getFonts().add(fntEntNew);

            //Add new Font-->Comic Sans MS
            fntEntNew = new FontEntity(pres, fntEnt);
            fntEntNew.setFontName("Comic Sans MS");
            int FontComicIdx = pres.getFonts().add(fntEntNew);

            //Add a textframe in first slide
            Slide sld = pres.getSlideByPosition(1);
            com.aspose.slides.Rectangle rect = (com.aspose.slides.Rectangle) sld.getShapes().addRectangle(600, 1000, 4700, 1);
            rect.addTextFrame("");
            rect.getLineFormat().setShowLines(false);

            //Set the TextFrame to wrap the text and adjust the shape automatically
            TextFrame tf = rect.getTextFrame();
            tf.setFitShapeToText(true);
            tf.setWrapText(true);

            //Change the font of the first portion to Times New Roman
            Portion fstPort = tf.getParagraphs().get(0).getPortions().get(0);
            fstPort.setText("This is first portion in Times New Roman. ");
            fstPort.setFontIndex(FontTimesIdx);

            //Change the font of the second portion to Comic Sans MS
            //First add the second portion
            tf.getParagraphs().get(0).getPortions().add(new Portion());
            Portion sndPort = tf.getParagraphs().get(0).getPortions().get(1);
            sndPort.setText("This is second portion in Comic Sans MS");
            sndPort.setFontIndex(FontComicIdx);

            //Write the presentation on disk
            File file = new File("c:\\Fonts.ppt");
            FileOutputStream fout = new FileOutputStream(file);
            pres.write(fout);
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }
}