java.lang.NullPointerException while using Aspose.Word jdk14

I am using Aspose.Words.jdk14

I am coming across an error

java.lang.NullPointerException: stream

when i try to save the pdf to an output stream

I am using doc.save(stream, SaveFormat.PDF);

If i give a local path, the pdf is generated at the given path.

if (pageContext.getParameter("submit") != null)
    DataObject fileUploadData = (DataObject)pageContext.getNamedDataObject("MessageFileUpload");

ByteArrayOutputStream stream = null;
stream = new ByteArrayOutputStream();
String fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, fileName);
byte[] in = uploadedByteStream.toByteArray();
ByteArrayInputStream inStream = new ByteArrayInputStream(in);
doc.save(stream, SaveFormat.PDF);

here the code breaks and an exception is thrown

catch (Exception ex)
{
    throw new OAException(ex.toString(), OAException.ERROR);
}

My reqt is to save the pdf in the database…So it is necessary for me to store the generated pdf in the output stream

I am able to execute the same code on R12 JDeveloper tool (version 10.1.3.3.0.3).

Issue is that my client uses on Java 1.4 11i Jdeveloper (version 9.3.3.0) and i face the above error in the lower version.

This message was posted using Email2Forum by Tahir Manzoor.

Hi Elvina,

Thanks for your inquiry. I have tested the scenario and have not found the shared issue while using latest version of Aspose.Words for Java 14.2.0. Please use the latest version of Aspose.Words for Java 14.2.0.

If the problem still remains, please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.

Could you please execute the following code snippet at your end and share your finding with us?

Document doc = new Document(MyDir + "in.docx");
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, SaveFormat.PDF);

I have tried using the jar you have provided. I come across the three errors on compilation :

Error: cannot access class com.aspose.words.ë61; file com\aspose\words\ë61.class not foundError: cannot access class com.aspose.words.ë61; file com\aspose\words\ë61.class not found
Error: cannot access class com.aspose.words.ë5L; file com\aspose\words\ë5L.class not foundError: cannot access class com.aspose.words.ë5L; file com\aspose\words\ë5L.class not found
Error(69,32): cannot access class asposewobfuscated.ë4M; file asposewobfuscated\ë4M.class not foundError(69,32): cannot access class asposewobfuscated.ë4M; file asposewobfuscated\ë4M.class not found.

On using the existing jar and the code provided by you above I get :

ByteArrayOutputStream stream = null;
stream = new ByteArrayOutputStream();
Document doc1 = new Document("C:\\Elvina\\test.docx"); 
doc1.save(stream, SaveFormat.PDF);

Error as below :

com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded

Hi Elvina,

Thanks for your inquiry. Aspose.Words for Java is available for Java 1.4, 1.5, 1.6 and 1.7 and will run in any place where Java is installed. Please make sure that you are using the Aspose.Words.14.2.jdk14.jar with JDK 1.4. I suggest you please create a separate Java application and check Aspose.Words.14.2.jdk14.jar.

If the problem still remains, please share following detail for investigation purposes.

What environment are you running on?

  • OS (Windows Version or Linux Version)
  • Architecture (32 / 64 bit)
  • Java version
  • Please attach your input Word document.

As soon as you get these pieces of information to us we’ll start our investigation into your issue.

Hello,

I have resoled the errors I was facing previously.

Currently this is my status:

I am using Aspose.words-jdk16-7.0.0.jar & java version 1.6.0_20.

I am able to convert .doc to .pdf successfully.

I am facing error on conversion of .docx to .pdf. I am using Microsoft Office 2013.

The word (.docx) file is a simple file having just 2 or 3 words of text.

Error :Aspose.Words.FileCorruptedException 

successfully

Please suggest what could be the error.

Hi Elvina,

Thanks for your inquiry. It is nice to hear from you that you have solved your problems.

emartis:

I am facing error on conversion of .docx to .pdf. I am using Microsoft Office 2013.

The word (.docx) file is a simple file having just 2 or 3 words of text.

Error :Aspose.Words.FileCorruptedException

I would suggest you please upgrade to the latest version (v14.2.0) from here and let us know how it goes on your side. If the problem still remains, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.

Hi,

When I change jar version to (v14.2.0) I face below errors on compilation.

Error: ë61 not found in class com.aspose.words.CompositeNode in class com.aspose.words.DocumentBase in class com.aspose.words.Document
Error: ë5L not found in class com.aspose.words.Document
Error(139,25): ë4M not found in class xxkoc.oracle.apps.per.irc.pdf.webui.XXKOCConvertToPdfCO.

Kindly let me know how to resolve this

Hi Elvina,

Thanks for your inquiry.

To ensure a timely and accurate response please supply us with the following information, if you cannot supply us with this information we will not be able to investigate your issue and raise a ticket.

  • Please attach your input Word document.
  • Please create a standalone/runnable simple Java application that demonstrates the code (Aspose.Words code) you used to reproduce this issue

Unfortunately, it is difficult to say what the problem is without the Document(s) and simplified application. We need your Document(s) and simple project to reproduce the problem. As soon as you get these pieces of information to us we’ll start our investigation into your issue.

Hi,

1.Using Aspose.words-jdk16-7.0.0.jar & java version 1.6.0_20 and any other MS Word (Except 2013) my requirments are fulfilled.
The error on using above is :
com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.

  1. If I use the one which you have provided latest version (v14.2.0)latest version (v14.2.0) then i get compilation error on a simple java application.
    Error: ë61 not found in class com.aspose.words.CompositeNode in class com.aspose.words.DocumentBase in class com.aspose.words.Document
    Error: ë5L not found in class com.aspose.words.Document
    Error(15,13): ë4M not found in class test.Class1.

My questions :

  1. Why does my system only support Aspose.words-jdk16-7.0.0.jar and not Aspose version (v14.2.0).
  2. Why does Aspose.words-jdk16-7.0.0.jar not support .docx ( MS office 2013).

Hi Elvina,

Thanks for your inquiry.

emartis:

1. Why does my system only support Aspose.words-jdk16-7.0.0.jar and not Aspose version (v14.2.0).

Aspose.Words for Java is available for Java 1.4, 1.5, 1.6 and 1.7 and will run in any place where Java is installed. Please read the system requirements from here:

https://docs.aspose.com/words/java/system-requirements/

Perhaps there is some issue at your side. As you are using JDK 1.6, please use the Aspose.Words.14.2.jdk16.jar Jar in your project.

Please remove all jar files from your application and include the latest Jar file of Aspose.Words for Java 14.2.0 (Aspose.Words.14.2.jdk16.jar). Hope this helps you.

Could you please create separate simple application which only loads the document at some different system and share your finding with us? I have successfully loaded the document into Aspose.Words DOM. Please check the attached image for detail.

emartis:

2. Why does Aspose.words-jdk16-7.0.0.jar not support .docx ( MS office 2013).

You are using very old version of Aspose.Words. The old version of Aspose.Words does not fully support MS Word 2013 documents.

Hi thanks for the reply. I have tried the same but still facing the issue.

Error

  • Error(140,22): ë4M not found in class xx.apps.per.irc.candidateSelfService.pdf.webui.XXPDFConverterCO
  • Error(201,17): ë78 not found in class com.aspose.words.DocumentBuilder in class xxkoc.oracle.apps.per.irc.candidateSelfService.pdf.webui.XXKOCPDFConverterCO
  • More error

I am running my code in,

  • Jdeveloper10g with JDK1.6
  • Aspose.Words.14.2.jdk16.jar
  • Windows 7

Could you please suggest what can be the issue.

Hi Elvina,

Thanks for sharing the detail. We will prepare the required platform to simulate the environment as of yours. As soon as everything is setup, we will test the issue at our end and will post the results here for your kind reference.

Thank you for your patience and understanding.

Hi Elvina,

Thanks for your patience.

I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSJAVA-867. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSJAVA-867) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,

This update has resolved my earlier issue.

I have attached a .doc document which has some identation and formatting issues when converted to pdf. Could you please explain.

Regards

Hi Elvina,

Thanks for your inquiry.

I have tested the scenario and have managed to reproduce the following issues at my side. For the sake of correction, I have logged this problems in our issue tracking system.

WORDSNET-9952 : The position of autotext field (ORACLE) is changed in output Pdf file

WORDSNET-9953 : Field in footer of document shows error in output Pdf (Error! No text of specified style in document. 1)

WORDSNET-9954 : The position of REF field ‘Subject’ is changed in output Pdf (‘Kuwait Oil Company’ is center aligned)

WORDSNET-9955 : Contents position is changed after conversion from Doc to Pdf (The contents of page number 6 moves up to the page number 5.)

I have linked this forum thread to the same issues and you will be notified via this forum thread once these issues are resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-9953) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-9952) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-9954) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.