Aspose slides conversion of PPT to PDF not working

Hello,

I am evaluating aspose api and for converting ppt to pdf, i am using Aspose.slides. I am getting error while loading the presentation.

my code is as below
FileInputStream fstream = new FileInputStream(folder + “\sample.ppt”);
com.aspose.slides.LoadOptions opts = new com.aspose.slides.LoadOptions();
opts.setLoadFormat(com.aspose.slides.LoadFormat.Ppt);

Presentation pres = new Presentation(fstream ,opts);

Error
java.lang.NoClassDefFoundError: Could not initialize class com.aspose.slides.ln
at com.aspose.slides.o0.(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Presentation.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Presentation.(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Presentation.(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]

ppt is sample ppt with just one slide with hello title.
I am using Jdk 11 and windows 10.

@JinuJoseph,
Welcome to our community! Thank you for the issue description. Could you please share the sample.ppt file for investigating the problem?

Hi,

I am not able to upload ppt. I am attaching an image of the ppt. Its a simple ppt with one slide and Hello text written. Same error with any ppt/pptx i try to convert.

Regards,
jinuppt_sample.png (45.4 KB)

@JinuJoseph,
I made simple presentations in PPT and PPTX formats and tested your code example. I have found no errors. Please check your application code and look at this post and Jared’s answer.

I have inlcuded Aspose pdf, word and email in same way and its working fine. I have added aspose slides jar to classpath as well. Still getting the same error.

@JinuJoseph,
In your case, I would suggest you to make a simple empty project containing your code example only with Aspose.Slides dependency and check the problem more isolated.

I have created a simple maven project and included only aspose slides. I am getting below error.

Exception in thread “main” java.lang.ExceptionInInitializerError
at com.aspose.slides.internal.oq.public.this(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.ano.(Unknown Source)
at com.aspose.slides.ln.(Unknown Source)
at com.aspose.slides.o0.(Unknown Source)
at com.aspose.slides.Presentation.do(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)
at sample.SampleConverter.main(SampleConverter.java:13)
Caused by: class com.aspose.slides.exceptions.ArgumentException: Illegal characters in path.
com.aspose.slides.internal.fs.catch.if(Unknown Source)
com.aspose.slides.internal.on.double.(Unknown Source)
com.aspose.slides.internal.oq.public.this(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.ano.(Unknown Source)
com.aspose.slides.ln.(Unknown Source)
com.aspose.slides.o0.(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.(Unknown Source)

@JinuJoseph,
Could you please share that maven project for checking the problem on our end?

sample.zip (2.0 MB)
Hello Mr. Potapov,
I have attached the sample project. Please check and let me know.
Regards,
Jinu

@JinuJoseph,
I checked your maven project and found no problems. ExceptionInInitializerError signals that an unexpected exception has occurred in a static initializer, but your code doesn’t have the static initializer.
Please check your code with my PPT sample sample.zip (22.0 KB), just in case.

I tried with the sample.ppt. I have same error. Cause of the error is Caused by: class com.aspose.slides.exceptions.ArgumentException: Illegal characters in path… This doesn’t seam like error due to missing jar or initializer. This is thrown from within aspose slides.jar.

@JinuJoseph,
Please check the next code example on your end and share the StackTrace string:

FileInputStream inputStream = new FileInputStream("<path to input PPT file>");

LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(LoadFormat.Ppt);
Presentation presentation = new Presentation(inputStream, loadOptions);

FileOutputStream outputStream = new FileOutputStream(new File("<path to output PDF file>"));
presentation.save(outputStream, SaveFormat.Pdf);
outputStream.close();

I have given the above code and executed. I am getting same error.

Exception in thread “main” java.lang.ExceptionInInitializerError
at com.aspose.slides.internal.oq.public.this(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.ano.(Unknown Source)
at com.aspose.slides.ln.(Unknown Source)
at com.aspose.slides.o0.(Unknown Source)
at com.aspose.slides.Presentation.do(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)
at sample.SampleConverter.main(SampleConverter.java:21)
Caused by: class com.aspose.slides.exceptions.ArgumentException: Illegal characters in path.
com.aspose.slides.internal.fs.catch.if(Unknown Source)
com.aspose.slides.internal.on.double.(Unknown Source)
com.aspose.slides.internal.oq.public.this(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.ano.(Unknown Source)
com.aspose.slides.ln.(Unknown Source)
com.aspose.slides.o0.(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.(Unknown Source)
com.aspose.slides.Presentation.(Unknown Source)
sample.SampleConverter.main(SampleConverter.java:21)
at com.aspose.slides.internal.fs.catch.if(Unknown Source)
at com.aspose.slides.internal.on.double.(Unknown Source)
… 10 more
Error.png (65.1 KB)

In com.aspose.slides.internal.fs.catch.if(Unknown Source) for what check is the error Illegal character in path thrown?

@JinuJoseph,
Our check for invalid characters in the file path fails. We’re trying to figure out why.

@JinuJoseph,
Please check the next code example on your end and share your output:

Process p = null;
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
try {
    if (OS.contains("windows 9")) {
        p = r.exec("command.com /c set");
    } else if (OS.contains("nt") || OS.contains("windows")) {
        p = r.exec("cmd.exe /c set");
    }
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = br.readLine()) != null) {
        int idx = line.indexOf('=');
        String key = line.substring(0, idx);
        String value = line.substring(idx + 1);
        System.out.println(key.toLowerCase()+ ", " + value);
    }
} catch (java.io.IOException e) {
    throw new IOException(e.getMessage(), e);
}

Also, please check the code example above on another machine as well.

From my machine.
allusersprofile, C:\ProgramData
appdata, C:\Users\csre8kk\AppData\Roaming
boiclct, 30000;OFF;CONT;NONE
boiparam, C:\Program Files (x86)\tab4\sys\boiparam.txt
boiroot, C:\Program Files (x86)\tab4
chrome, C:\Program Files (x86)\Google\Chrome\Application
classpath, .;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\DB2JCC~1.JAR;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\Program Files (x86)\MQClient\java\lib\com.ibm.mqjms.jar;C:\Program Files (x86)\MQClient\java\lib\com.ibm.mq.jar
commonprogramfiles, C:\Program Files\Common Files
commonprogramfiles(x86), C:\Program Files (x86)\Common Files
commonprogramw6432, C:\Program Files\Common Files
computername, CS601171
comspec, C:\WINDOWS\system32\cmd.exe
dadir, C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common
db2instance, DB2
driverdata, C:\Windows\System32\Drivers\DriverData
fps_browser_app_profile_string, Internet Explorer
fps_browser_user_profile_string, Default
homedrive, M:
homepath,
homeshare, \\WWG00M.ROOTDOM.NET\DFS\HOME\csre8kk
itwatchfolder, C:\Program Files (x86)\itWatch
itwatchfolder_64, C:\Program Files\itWatch
localappdata, C:\Users\csre8kk\AppData\Local
logonserver, \DCE02A05
logs, C:\temp\logs
mqchllib, C:\Program Files (x86)\MQClient\ADAG\CHLTAB
mqerrorpath, C:\Temp\Logs\MQClient
mqtracepath, C:\Temp\Logs\MQClient
mq_adag_exit_path, C:\Program Files (x86)\MQClient\Exits
mq_file_path, C:\Program Files (x86)\MQClient
mq_java_data_path, C:\Program Files (x86)\MQClient
mq_java_install_path, C:\Program Files (x86)\MQClient\java
mq_java_lib_path, C:\Program Files (x86)\MQClient\java\LIB
mq_jre_path, C:\Program Files (x86)\MQClient\java\jre
mq_keep_locale, 1
number_of_processors, 4
onedrive, C:\Users\Administrator\OneDrive
os, Windows_NT
osver, Windows10_ID
path, C:\ProgramData\Oracle\Java\javapath;C:\ORACLE\product\11.2.0.3\client32_1\bin;C:\ORACLE\product\11.2.0.3\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\Program Files (x86)\MQClient\bin64;C:\Program Files (x86)\MQClient\bin;C:\Program Files (x86)\MQClient\Exits;C:\Program Files (x86)\MQClient\ADAG\bin;C:\Program Files (x86)\MQClient\Exits64;C:\Program Files (x86)\MQClient\ADAG\bin64;C:\Program Files (x86)\ooRexx;C:\Program Files (x86)\ALIS;C:\Program Files (x86)\CID;C:\Program Files\komtva\bin;C:\Program Files (x86)\komtva\bin;C:\Program Files (x86)\tab4\bin;C:\Program Files (x86)\prismaclient;C:\Program Files\nodejs;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Program Files (x86)\itWatch;C:\Program Files (x86)\Webex\Plugins;C:\Program Files (x86)\Sennheiser\SoftphoneSDK;C:\Users\csre8kk\AppData\Local\Microsoft\WindowsApps;
pathext, .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
prismaappdatadir, C:\ProgramData\prisma
prismabasedir, C:\Program Files (x86)\prismaclient
processor_architecture, AMD64
processor_identifier, Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
processor_level, 6
processor_revision, 8e09
programdata, C:\ProgramData
programfiles, C:\Program Files
programfiles(x86), C:\Program Files (x86)
programw6432, C:\Program Files
prompt, $P$G
psmodulepath, C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
public, C:\Users\Public
rexx_home, C:\Program Files (x86)\ooRexx
saplogon_lsxml_file, M:\Anwendungsdaten\SAPGUI\SAPUILandscape.xml
sessionname, Console
snc_lib, C:\Program Files (x86)\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
snc_lib_64, C:\Program Files\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
ssf_library_path, C:\Program Files (x86)\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
ssf_library_path_64, C:\Program Files\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
systemdrive, C:
systemroot, C:\WINDOWS
temp, C:\Users\csre8kk\AppData\Local\Temp
tmp, C:\Users\csre8kk\AppData\Local\Temp
tns_admin, C:\ORACLE\product\11.2.0.3\client32_1\network\admin
tvdumpflags, 8
uatdata, C:\Windows\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77

userprofile, C:\Users\csre8kk
windir, C:\WINDOWS
zovi_root, C:\Program Files (x86)\adagzovi\zsv

@JinuJoseph,
Please check the next code example on your end and share your output:

        System.out.println(System.getProperty("file.encoding"));
        Charset defaultCharset = Charset.defaultCharset();
        System.out.println(defaultCharset.name());

        char[] illegalChars = new char[]{'\"', '\u003C', '\u003E', '\u007C', '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
                '\u0008', '\u0009', '\n', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', '\u0011', '\u0012',
                '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D',
                '\u001E', '\u001F'};

        Process p = null;
        Runtime r = Runtime.getRuntime();
        String OS = System.getProperty("os.name").toLowerCase();
        try {
            if (OS.contains("windows 9")) {
                p = r.exec("command.com /c set");
            } else if (OS.contains("nt") || OS.contains("windows")) {
                p = r.exec("cmd.exe /c set");
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = br.readLine()) != null) {
                int idx = line.indexOf('=');
                String key = line.substring(0, idx);
                String value = line.substring(idx + 1);
                if ("windir".equals(key.toLowerCase()))
                {
                    String fullpath = value + "\\Fonts";
                    System.out.println(fullpath);
                    for (char illegal : illegalChars){
                        int index = fullpath.indexOf(illegal);
                        if (index != -1)
                            System.out.println(String.format("Illegal characters in path - \"%s\"", fullpath.substring(index, index + 1)));
                    }
                }
            }
        } catch (java.io.IOException e) {
            throw new IOException(e.getMessage(), e);
        }

Cp1252
windows-1252
C:\WINDOWS\Fonts

@JinuJoseph,
Please try the next solution. Click the right button on your Eclipse project and select Properties. Click the Resource tab and select UTF-8 for Text file encoding settings settings.png (21.1 KB)
.