Problem converting .doc to .pdf using Linux

Dear Aspose Team,

we have a problem converting .doc documents to .pdf using your new feature in the Aspose.Words API.

First of all, here is the code:

Document doc = new Document(source);
// Workaround Beta 4.0.0
for (Section sect = doc.getFirstSection();
sect != null; sect = (Section)sect.getNextSibling())
{
    PageSetup pageSetup = sect.getPageSetup();
    pageSetup.setFirstPageTray(PaperTray.DEFAULT_BIN);
    pageSetup.setOtherPagesTray(PaperTray.DEFAULT_BIN);
}
doc.saveToPdf(target);

When we’re running this code on a Windows system, everything works great. When we try to run the code using openSUSE 10.2 you’ll get a NullPointerException. We saw that the Exception must appear at doc.saveToPdf(target).

Do you have any idea why it runs with Windows but not with Linux?

On the Linux system there is installed:
java version “1.5.0_14”
Java™ 2 Runtime
Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot™
Client VM (build 1.5.0_14-b03, mixed mode,
sharing)

Best regards

Hi Frank,

Thanks for your request. Does the some particular document causes the problem or the exception is thrown when you try to convert any Word document to PDF in Linux environment? Could you please attach your document here for testing? I will check the issue on my side and provide you more information.

Best regards.

Hi,

attached you’ll find a sample document. We tried it with another but that doens’t work, too. No we’ll try it with a more simple document.

Best regards.

Hi

Thank you for additional information. At the moment I do not have Linux installed. I will install Linux on Virtual Machine, check the issue and provide you more information. Please expect a reply in few hours.

Best regards.

Hi

I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

Best regards.

Hello,

is there a workaround for gernerating pdf documents under linux?

With best regards.

hSp

Hi

Thanks for your request. Have you tried specifying TrueTypeFontsFolder?

Document doc = new Document("/usr/alexey/in.doc");
PdfOptions opt = new PdfOptions();
opt.setTrueTypeFontsFolder("/usr/share/fonts");
doc.saveToPdf(0, doc.getPageCount(), "/usr/alexey/out.pdf", opt);

Hope this helps.

Hello, thanks for your help.

I set the fonts folder. Now i got another exception:

[java.lang.IllegalStateException] <<>>

Do you have another workaround?

I think the method doc.getPageCount() will fail.

Could you check it?

Best regards.

Frank

Hi Frank,

Thanks for your request. Unfortunately, I cannot suggest you any other way to work the problem around. You should note, this feature is in beta at the moment.

Best regards.

Hi Alexey,

thanks for your fast answer. Please could you make a assumption, when the beta status is leaved?

With best regards,

Frank

Hi

Thanks for your request. Most likely conversion to PDF in Aspose.Words for Java will be out of beta somewhere in February. I will notify you.

Best regards.

The issues you have found earlier (filed as 13297) have been fixed in this update.


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

Hello, i tried the new beta 4.0.1

but under linux i get a exception:

[java.lang.IllegalStateException] <<>> !!!MSWordServer3: MSWS.createPDF() failed! /maris/doc/313884-412040.doc->/maris/doc/313884-412040.pdf!!!

like in the post before.

Could you chek this?

With best regards.

Frank

Hi Frank,

Thanks for your request. I checked conversion on my side and all works fine. Here is code I used for testing:

Document doc = new Document("/home/alexey/in.doc");
PdfOptions opt = new PdfOptions();
opt.setTrueTypeFontsFolder("/home/alexey/fonts");
doc.saveToPdf(0, doc.getPageCount(), "/home/alexey/in.pdf", opt);

Best regards.

Hello Alexey,

i got the problems at doc.getPageCount().

Here ist the Java VM i used: java -version

java version “1.5.0_14”
Java™ 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot™ Client VM (build 1.5.0_14-b03, mixed mode, sharing)

of course i know that java v1.5 is out of date, but i have to use it.

when the code reaches the line:

System.out.println(“Anzahl Seiten” + doc.getPageCount());

the code crashes with a NullPointerException:
[java.lang.NullPointerException] (No exception message available!)

Is it possible, that is a java v1.5 bug?

EDIT:
I have tried the java v1.6 update 18 too using the aspsose.words.jdk16.jar. I also tried the following code:

Document test = new Document();
DocumentBuilder builder = new DocumentBuilder(test);
builder.writeln("Hello World!");
test.save("/maris/doc/test.doc"); 
test.saveToPdf(0, test.getPageCount(), "/maris/doc/test.pdf", opt);

Independent of building a document with Aspose our using my own I allways get the Exception:
[java.lang.IllegalStateException] <<>>

I think the getPageCount method throws this exception!

Please could you test the enclosed docuement file?

With best regards.

Frank

Hi Frank,

Thank you for additional information. I tried one more time with the document you attached and all works fine on my side. I tested on Ubuntu 9.0.1 with Sun JDK 1.6.

Best regards.

Hi Alexey,

to ensure the error don’t causes in our system I build a simple class file:


import com.aspose.words.Document;
import com.aspose.words.PdfOptions;

public class pdfTest
{
    public static void main(String[] args)
    {
        try
        {
            System.out.println("creating doc");
            Document doc = new Document("/maris/doc/test.doc");
            System.out.println("doc created");

            System.out.println("creating PDF Options");
            PdfOptions opt = new PdfOptions();
            opt.setTrueTypeFontsFolder("/usr/share/fonts/truetype"); <- this isn’t the standard path
            System.out.println("PDF Options created");

            System.out.println("creating PDF");
            doc.saveToPdf(0, doc.getPageCount(), "/maris/doc/test.pdf", opt);
            System.out.println("PDF created");

        } catch (Exception e)
        {
            System.out.println("Error: " + e);
        }
    }
}


When running this file I got the following output:

creating doc
doc created
creating PDF Options
PDF Options created
creating PDF
Error: java.lang.IllegalStateException: End of file reached.

I tried this .class using Sun JRE 1.6.0_18 and Sun JDK 1.6.0_18 but I allways got the same error. We installed them to /usr/java and changed the java link in /usr/bin. We allways use the openSuSE operating system in the Version 10.1, 10.2 and 10.3. Is it possible that you can test or debug it on this operating system?
Here you’ll find a complete VM with openSuSe 10.1: http://www.vmware.com/appliances/directory/508

Thanks for the help!

Frank

Hi

Thank you for additional information. But I cannot download OpenSuse image from the link you provided. All download links provided there are dead. I will try to install OpenSuse from scratch on my side or find another image. I will let you know how it goes on my side.

Best regards.

Thank you very much.

With best regards.

Frank

Hi All,
I have been working on a similar problem:

java -version:
java version “1.6.0_17”
Java™ SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot™ 64-Bit Server VM (build 14.3-b01-101, mixed mode)

(OS X 10.5)

With this code:

try
{
    Document document = new Document("aspose_input_template.docx");
    log.debug("Saving to PDF");

    PdfOptions opt = new PdfOptions();
    // opt.setTrueTypeFontsFolder("/Library/Fonts");
    log.debug("Font path set");

    int pageCount = document.getPageCount();
    log.debug("There are " + pageCount + " pages in the resulting document");

    document.saveToPdf(0, pageCount, "aspose.CustomDataSource.basic OUT.docx", opt);
}
catch (Exception e)
{
    Assert.fail("Error while saving output file: " + e.getMessage());
}

I get:
Error while saving output file: null

With the line:
opt.setTrueTypeFontsFolder("/Library/Fonts");

Uncommented, I get:
Error while saving output file: End of file reached.

(which is from the getPageCount() call)

So the behaviour is different with and without the fonts being set.

HTH

Anthony