PDF creation fails when converting word document to PDF

Hello.

I’ve got a strange red cross when converting the attached file to PDF. Can you have a look please?

Kind regards,

JP.

Hi Renato,

Thanks for your inquiry.

Perhaps you’re using an older version of Aspose.Words; as with Aspose.Words for Java v11.11.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v11.11.0. You can download it from the following link:

https://downloads.aspose.com/words/java

I hope, this helps.

Moreover, I have attached a PDF document that is generated on my side here for your reference.

Best regards,

Hi,

This is JP using Renato’s account.

I’m using the latest version of Aspose Total Java. I downloaded it yesterday. If Total Java doesn’t contain the latest version of Aspose.Words, please update it.

I’m about to compare your version included with Total Java and your version in Aspose Words. I suspect they aren’t the same because I tested with Total Java.

Kind regards,

JP.

Hi.

This is JP again.

I can confirm that my file is the latest as follows:

-r–r--r-- 1 sroot sroot 7284424 2013-01-30 17:53 Aspose.Words.jdk16.jar

I can also confirm that Total Java and Aspose Words both share the same file.

My development environment is Ubuntu 11.10 and my production environment is Ubuntu too. What is the OS you’ve tried?

Do you think my OS misses some kind of image engine? If yes, what?

Please find attached the resulting file.

Kind regards,

JP.

Hi,

Thanks for the additional information. To ensure a timely and accurate response please supply us with the following information.

  • What Java version (JDK) are you running on your Linux machine(s)?
  • Are you getting this problem on both your development and production machines? If not, please share the environment difference.
  • Are you using any Third Party Libraries / SDK in addition to Aspose Products?
  • Please supply us with the code from your application that is causing the issue

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

Moreover, previously I did test your scenario on 64-bit Windows-7 OS on my side and found nothing wrong in the generated PDF.

Many thanks,

My Operating System in development is: Ubuntu 11.10 64 bits.

**My java in development environment is:
sroot@schulerbox:~$ java -version
java version “1.6.0_23”
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

My java in production environment is:
java -version
java version “1.6.0_20”
OpenJDK Runtime Environment (IcedTea6 1.9.9) (6b20-1.9.9-0ubuntu1~10.04.2)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

My Source code is:

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collections;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.net.URI;
import java.awt.Color;
import java.util.regex.Pattern;
import com.aspose.words.*;

...

//convert word to pdf
public static void word_pdf(String input, String output) throws Exception
{
//get the source input
Document srcDoc = new Document(input);
srcDoc.save(output);
}

I’m getting the same error on both development and production.

I’m not loading any other jar file.

Should I update my JVM?

Kind regards,
JP. My Operating System in development is: Ubuntu 11.10 64 bits.

My java in development environment is:
sroot@schulerbox:~$ java -version
java version “1.6.0_23”
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

My java in production environment is:
java -version
java version “1.6.0_20”
OpenJDK Runtime Environment (IcedTea6 1.9.9) (6b20-1.9.9-0ubuntu1~10.04.2)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

My Source code is:

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collections;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.net.URI;
import java.awt.Color;
import java.util.regex.Pattern;
import com.aspose.words.*;

...

//convert word to pdf
public static void word_pdf(String input, String output) throws Exception
{
//get the source input
Document srcDoc = new Document(input);
srcDoc.save(output);
}

I’m getting the same error on both development and production.

I’m not loading any other jar file.

Should I update my JVM?

Kind regards,
JP.

I’ve just found a couple of things that might help.

  1. If I compress the image (Using Word Image Tool), the problem goes away.

  2. If I “save as” the original document as “docx”, I get the following error:

Exception: java.lang.RuntimeException: javax.imageio.IIOException: Invalid icc profile: bad sequence number
java.lang.RuntimeException: javax.imageio.IIOException: Invalid icc profile: bad sequence number
at asposewobfuscated.ëFG.ëCJ(Unknown Source)
at asposewobfuscated.ëFG.ëDh(Unknown Source)
at asposewobfuscated.ëFF.ëY(Unknown Source)
at asposewobfuscated.ëH4.ëZ(Unknown Source)
at asposewobfuscated.ëH4.ëS(Unknown Source)
at asposewobfuscated.ëH5.endDocument(Unknown Source)
at asposewobfuscated.ëFS.endDocument(Unknown Source)
at com.aspose.words.ë3K.ëd8(Unknown Source)
at com.aspose.words.ëLO.ëZ(Unknown Source)
at com.aspose.words.Document.ëZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at Main.word_pdf(Main.java:113)
at Main.main(Main.java:54)
Caused by: javax.imageio.IIOException: Invalid icc profile: bad sequence number
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(JPEGImageReader.java:593)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader.java:338)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:470)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(JPEGImageReader.java:586)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1004)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readRaster(JPEGImageReader.java:1362)
at asposewobfuscated.ëIM.ëZ(Unknown Source)
at asposewobfuscated.ëIM.ëT(Unknown Source)
at asposewobfuscated.ëIM.(Unknown Source)
at asposewobfuscated.ëFG.ëCJ(Unknown Source)
... 13 more

I hope it helps.

Kind regards,

JP.

The file that provokes above exception is attached to this reply (in the case it helps)

Hi,

Thanks for the additional information.

I will prepare the required platform to simulate the environment as of yours. As soon as everything is set up, I will test your issues on my end and post the results here for your kind reference. We apologize for any inconvenience.

Best regards,

How is your testing doing?

Kind regards,

JP.

Hi,

Thanks for your inquiry. Unfortunately, I was unable to reproduce your issues on my side. I tested your scenarios on the following environments:

Ubuntu release version: 12.04

Oracle’s Java version: 1.6 and 1.7

Generally speaking, most of our Java products depend upon the JAI package (Java Advanced Imaging) from Sun in order to process images. By looking at the stack trace, it seems your problem is somehow related to JAI. I would suggest you please ask your question in some JAI community e.g. here:
https://docs.aspose.com/words/java/system-requirements/#optional-dependencies

Please let me know if I can be of any further assistance.

Best regards,

Thank you so much for your support.

The package you recomend is available since ubuntu 12 as can be seen at:
https://docs.aspose.com/words/java/system-requirements/#optional-dependencies

The problem is: my development and production invironments are not version 12. So, it seems I have to upgrade my ubuntu and install jai.

Thank you again,

JP.

Hi,

Sure, we will wait for your feedback on this. Thanks for your cooperation.

Best regards,

Hi.

Please add to your notes:

After upgrading to Ubuntu 12.04 LTS, the problem persisted. Then, after upgrading from Open JDK 1.6 to Open JDK 1.7, the problem was resolved. It works with Open JDK 1.7.

Thank you for providing the path towards the solution,

JP.

Hi,

Thanks for the additional information. Please find attached the JPEG image that I have extracted from the document you attached here. Could you please run the following code snippet with Open JDK 1.6 and Open JDK 1.7 on your side and let us know if you still manage to reproduce the exception.

public static void main(String args[]) {
    try {
        ImageIO.read(new File("C:\\Temp\\image1.jpeg"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Best regards,