NullPointer on saving Word2007 OOXML file to PDF

java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) Client VM (build 20.7-b02, mixed mode)

Windows 2008 SP2 32bit



Aspose Words for Java 11.7.0 downloaded 19/09/2012

I have a trivial aspose program which takes the attached file as input and attempts to save it as PDF. Whilst I have not had problems with some other simple Word 2007 files, with this one I am getting a NullPointer exception.

private static void transformDocXToPDFUsingAspose(File in, File out) throws Exception
{
long start = System.nanoTime();
System.out.println("Begin transformDocXToPDFUsingAspose");
Document doc = new Document(in.getAbsolutePath());

System.out.println("loaded doc in transformDocXToPDFUsingAspose");
doc.save(out.getAbsolutePath());
long taken = System.nanoTime() - start;
System.out.println("End transformDocXToPDFUsingAspose: " + (taken/1000000) + "ms");
}

gives

Begin transformDocXToPDFUsingAspose
loaded doc in transformDocXToPDFUsingAspose
java.lang.NullPointerException
at com.aspose.words.E.CC(Unknown Source)
at com.aspose.words.H6.Ã(Unknown Source)
at com.aspose.words.H6.dQ(Unknown Source)
at com.aspose.words.H6.dS(Unknown Source)
at com.aspose.words.H6.U(Unknown Source)
at com.aspose.words.HC.T(Unknown Source)
at com.aspose.words.HB.S(Unknown Source)
at com.aspose.words.HB.Y(Unknown Source)
at com.aspose.words.X7.Ã(Unknown Source)
at com.aspose.words.ZQ7.ZII(Unknown Source)
at com.aspose.words.ZQ7.Ã(Unknown Source)
at com.aspose.words.YQ.Y(Unknown Source)
at com.aspose.words.ZVB.R(Unknown Source)
at com.aspose.words.X7.Ã(Unknown Source)
at com.aspose.words.ZQ7.ZII(Unknown Source)
at com.aspose.words.ZQ7.Ã(Unknown Source)
at com.aspose.words.Y2.xJ(Unknown Source)
at com.aspose.words.Y2.Y(Unknown Source)
at com.aspose.words.ZXQ.K(Unknown Source)
at com.aspose.words.ZXQ.T(Unknown Source)
at com.aspose.words.ZXB.E(Unknown Source)
at com.aspose.words.ZOX.UV(Unknown Source)
at com.aspose.words.VM.Z7(Unknown Source)
at com.aspose.words.VN.ti(Unknown Source)
at com.aspose.words.IB.Ã(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.Zb(Unknown Source)
at com.aspose.words.Document.tO(Unknown Source)
at com.aspose.words.Document.getPageCount(Unknown Source)
at com.aspose.words.NE.Ã(Unknown Source)
at com.aspose.words.Document.Ã(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at uk.co.his.test.docTemplate.prototypes.word2007.TestHarness.transformDocXToPDFUsingAspose(TestHarness.java:406)
at uk.co.his.test.docTemplate.prototypes.word2007.TestHarness.testPDFConvertors(TestHarness.java:135)



Hi,

Thanks for your query. I have tested the scenario over following Operating Systems and have not faced the exception while using latest version of Aspose.Words for Java 11.7.0. It would be great if you please convert Docx to pdf again by using latest version of Aspose.Words for Java. I have attached the output PDF files with this post.

Windows Server 2008 64 bit
Windows Server 2003
Window XP
Window 7 64/32 bit

Downloaded
Aspose.Words for Java 11.7.0. again. Has it changed?

Re-ran test. Same output.

What version of Java are you using?
Do you have a copy of Windows Server 2008 SP2 (not R2 which is only 64bit) 32bit?
Does Aspose Java rely in any way on .Net on a Windows platform?

Any clues in why something might crash at this location - what would have to be wrong with the document?

Hi,

Thanks for your query. I tested the scenario with Aspose.Words for Java 11.7.0.

JFK99:
Downloaded Aspose.Words for Java 11.7.0. again. Has it changed?
Re-ran test. Same output.

Are you still getting the exception? If Yes, we will prepare the required platform (Windows Server 2008 SP2 32 bit) to simulate the environment as of yours. We will test this issue at our end and will post the results here.

Yes it is the same exception.

To save you having to install a box, if you tell me what version of Java you are running perhaps I can simulate the (lack of) problem here ( it’ll have to be a 32bit version of Java obviously).
Assume that .Net install has nothing to do with it.

Thanks for your support!

Hi,


Thanks for sharing the details. I used jdk1.6.0_23 to convert Docx to PDF.

Tried with JDK 1.6.0_23 and still have same problem…

Does Aspose Java use an XML parser, and a standard API like JAXP to pick it up?

My example is being run from an Eclipse project with a fairly exotic XML classpath, due to unfixed JDK bugs, that might account for the problem. I will try a completely vanilla JDK project
Tried starting with an empty Eclipse Java project, but with JUnit4 on classpath.


Still Windows Server 2008 SP2 32bit

java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) Client VM (build 20.7-b02, mixed mode)

Here is the complete example code, followed by the stack trace of the Exception;

package uk.co.his.asposetest;

import java.io.File;

import org.junit.Test;


import com.aspose.words.Document;

public class TestIt
{
private static final String PDFOUT = "test-results/TestConvert-aspose.pdf";
private static final String DOCXIN = "resources/TestConvert.docx";
@Test
public void test()
{
try
{
transformDocXToPDF(new File(DOCXIN), new File(PDFOUT));
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void transformDocXToPDF(File in, File out) throws Exception
{
transformDocXToPDFUsingAspose(in, out);
}
private static void transformDocXToPDFUsingAspose(File in, File out) throws Exception
{
long start = System.nanoTime();
System.out.println("Begin transformDocXToPDFUsingAspose");
Document doc = new Document(in.getAbsolutePath());

System.out.println("loaded doc in transformDocXToPDFUsingAspose");
doc.save(out.getAbsolutePath());
long taken = System.nanoTime() - start;
System.out.println("End transformDocXToPDFUsingAspose: " + (taken/1000000) + "ms");
}
}





Begin transformDocXToPDFUsingAspose
loaded doc in transformDocXToPDFUsingAspose
java.lang.NullPointerException
at com.aspose.words.E.CC(Unknown Source)
at com.aspose.words.H6.Ã(Unknown Source)
at com.aspose.words.H6.dQ(Unknown Source)
at com.aspose.words.H6.dS(Unknown Source)
at com.aspose.words.H6.U(Unknown Source)
at com.aspose.words.HC.T(Unknown Source)
at com.aspose.words.HB.S(Unknown Source)
at com.aspose.words.HB.Y(Unknown Source)
at com.aspose.words.X7.Ã(Unknown Source)
at com.aspose.words.ZQ7.ZII(Unknown Source)
at com.aspose.words.ZQ7.Ã(Unknown Source)
at com.aspose.words.YQ.Y(Unknown Source)
at com.aspose.words.ZVB.R(Unknown Source)
at com.aspose.words.X7.Ã(Unknown Source)
at com.aspose.words.ZQ7.ZII(Unknown Source)
at com.aspose.words.ZQ7.Ã(Unknown Source)
at com.aspose.words.Y2.xJ(Unknown Source)
at com.aspose.words.Y2.Y(Unknown Source)
at com.aspose.words.ZXQ.K(Unknown Source)
at com.aspose.words.ZXQ.T(Unknown Source)
at com.aspose.words.ZXB.E(Unknown Source)
at com.aspose.words.ZOX.UV(Unknown Source)
at com.aspose.words.VM.Z7(Unknown Source)
at com.aspose.words.VN.ti(Unknown Source)
at com.aspose.words.IB.Ã(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.Zb(Unknown Source)
at com.aspose.words.Document.tO(Unknown Source)
at com.aspose.words.Document.getPageCount(Unknown Source)
at com.aspose.words.NE.Ã(Unknown Source)
at com.aspose.words.Document.Ã(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at uk.co.his.asposetest.TestIt.transformDocXToPDFUsingAspose(TestIt.java:41)
at uk.co.his.asposetest.TestIt.transformDocXToPDF(TestIt.java:31)
at uk.co.his.asposetest.TestIt.test(TestIt.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Hi,

Thanks for the additional information. We will prepare the required platform (Windows Server 2008 SP2 32bit) to simulate the environment as of yours. As soon as everything is setup, we will test the issue on our end and will post the results here for your kind reference.

Thank you for your patience and understanding.

Hi,


Thanks for your patience.

I have tested the scenario at following environment and have not found any exception. Please use the latest version of Aspose.Words for Java 11.8.0. I have attached the output PDF file with this post.
  • Aspose.Words for Java 11.8.0
  • Windows Server 2008 SP2 32bit
  • Net Beans 7.0 (jdk1.6.0_23)

Tried it again here with the latest version of Aspose.Words for Java 11.8.0 and that seems to have fixed the problem. Thanks.

Hi,


Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.