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)
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.
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.
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.
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.
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
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.
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.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.