Error while converting word document to pdf

Hi,

We are using Aspose.Words for Java to convert word document(.doc) to Pdf. It is working fine in Windows XP, however for Windows 7 its throwing below exception-

java.lang.NullPointerException
at asposewobfuscated.il.getFontsFolders(ExternalFontCache.java:108)
at asposewobfuscated.il.ja(ExternalFontCache.java:204)
at asposewobfuscated.il.iY(ExternalFontCache.java:161)
at asposewobfuscated.il.d(ExternalFontCache.java:126)
at asposewobfuscated.ht.d(DocumentFontCache.java:36)
at asposewobfuscated.ip.a(FontCacheBase.java:21)
at com.aspose.words.o.a(AttributeConverter.java:41)
at com.aspose.words.fj$b.G(DocumentRunSplitter.java:476)
at com.aspose.words.fj$b.moveNext(DocumentRunSplitter.java:448)
at com.aspose.words.fj.a(DocumentRunSplitter.java:181)
at com.aspose.words.apk.c(RunWriter.java:316)
at com.aspose.words.apk.Zb(RunWriter.java:170)
at com.aspose.words.apk.a(RunWriter.java:138)
at com.aspose.words.fj.(DocumentRunSplitter.java:78)
at com.aspose.words.asa.a(SpanGenerator.java:226)
at com.aspose.words.fk.aK(DocumentSpanConverter.java:689)
at com.aspose.words.fk.EV(DocumentSpanConverter.java:629)
at com.aspose.words.fk.moveNext(DocumentSpanConverter.java:169)
at com.aspose.words.fk.Es(DocumentSpanConverter.java:205)
at com.aspose.words.wd.a(LayoutDocument.java:44)
at com.aspose.words.Document.updatePageLayout(Document.java:1454)
at com.aspose.words.Document.az(Document.java:1393)
at com.aspose.words.Document.Dk(Document.java:1406)
at com.aspose.words.Document.getPageCount(Document.java:1435)
at com.aspose.words.pt.a(FixedPageWriterBase.java:22)
at com.aspose.words.Document.a(Document.java:1346)
at com.aspose.words.Document.a(Document.java:803)
at com.aspose.words.Document.save(Document.java:780)

Below is the code snippet of how we are converting doc to pdf -

Document wordStream;
ByteArrayOutputStream boPDF = new ByteArrayOutputStream();
wordStream = new Document(fileInputStream);
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setSaveFormat(SaveFormat.PDF);
wordStream.save(boPDF, saveOptions);

Manifest file entry for Aspose.word jar which we are using -
Manifest-Version: 1.0
Specification-Title: Aspose.Words for Java
Specification-Version: 10.5.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Title: Aspose.Words for Java
Implementation-Version: 10.5.0.0
Implementation-Vendor: Aspose Pty Ltd
Release-Date: 2011.09.30

Pls let me know what needs to be done to resolve this issue.
Quick response will be appreciated.

Regards,
Sahil Kumar

Hi Sahil,

Thanks for your inquiry. Could you please attach your input Word document, you’re getting this problem with, here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

Hi Hafeez,

Please find attached sample document, however this issue is happening for each and every word document.

I also request you to delete this document once it is not required.

Thanks,
Sahil Kumar

Hi Sahil,

Thanks for your request.

Perhaps, you’re using an older version of Aspose.Words; as with Aspose.Words v11.4.0, I was unable to reproduce this exception on my side during rendering your DOC file to PDF format. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v11.4.0. I hope, this will help.

Moreover, I have attached the PDF file, i.e. generated on my side on Windows-7 platform, here for your reference.

Best Regards,

Thanks Hafeez. With latest version of Aspose.Words, it worked. But it’s not able to find exact font of the document.After converting to pdf, font is Times New Roman, however original document has custom organization wide font. Please let me know if any other settings need to be done.
Your efforts are really appreciable.

Regards,
Sahil Kumar

Hi Sahil,

Thanks for your inquiry.

Please note that when you render Word documents to fixed-page formats e.g. PDF, Aspose.Words requires TrueType fonts to be installed on the operating system. Please make sure, if the desired fonts are installed on your side? Moreover, you can specify the location of the folder that contains the font by using the following code snippet:

Document doc = new Document(MyDir + "Rendering.doc");
// Set fonts to be scanned for under the specified directory. Do not search within folders nested this folder.
FontSettings.SetFontsFolder(@"C:\MyFonts\", false); 
doc.Save(MyDir + "SetFontsFolder Out.pdf");

I hope, this will help.

Best Regards,

Thanks Hafeez!!! I am able to resolve this issue with your help.
However, I have observed another issue. After converting word document to pdf document, text is getting shifted and some time it get shrink as well. Pls let me know if any scalling properties are required to set.
To replicate this issue, you can use any word document (.doc), get that converted to pdf using Aspose Word, take printout of both the document and hold both the pages together (one over other) and check over a light source, you can easily see the difference.

Appreciate your efforts you made so far.

Thanks,
Sahil Kumar

Hi Sahil,

Thanks for the additional information.

First of all, it is perfect that you managed to resolve the problem on your side.

Secondly, please note that we don’t change anything in Font during rendering Word documents to PDF format. I tried printing sample Word/PDF documents, i.e. generated with the latest version of Aspose.Words, on my side and I do see negligible differences there. But, we don’t think this as a bug in Aspose.Words since Aspose.Words tries to mimic the way the Microsoft Word’s page layout engine works. Moreover, could you please attach your Word document, you’re getting this font problem, here for testing? I will investigate the issue further on my side and provide you more information.

Best Regards,

Hi Hafeez,

Please find the sample document attached herewith. Pls compare both word and pdf printout. You can see significant shifting in text. Font is same, only issue is text is getting shifted.
If you are still not able to replicate the issue than please let me know which version of aspose.word you are using.

Thanks,
Sahil Kumar

Also Haffez, We have product license. Can we have support numbers to get this issue moving quickly?

Thanks,
Sahil

Hi
Sahil,

Thanks for your inquiry and sorry for the delayed response.

I tried printing both your Word document and the PDF file (i.e. generated on my side by using Aspose.Words for JAVA v11.5.0) to XPS file by using '‘Microsoft XPS Document Writer’ and was unable to spot any differences. I have attached the XPS files here with this post for your reference.

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

Best Regards,

Hi Hafeez,

Thanks for your reply.

We checked further and found that the issue does not happen with all samples of word document that we have. I have attached a new sample with this reply. We are able to replicate the issue with this sample. Request you to please test with this sample.

Also I would suggest to do the verification in following way:

  1. Print the pdf document generated using aspose (after conversion from word to pdf) to printer
  2. Print the original word document using office to printer
  3. Hold both the pages together (one over other) and check over a light source and check if the printouts are a exact match or not

Regards,
Sahil Kumar

Hi
Sahil,

Thanks for your inquiry. But, when I tried printing your ‘IT_Umschreibung Code 178-Brief an Strassenverkehrsamt.doc’ by using MS Word 2007, the application crashed on my side. I was also not able to convert your document to even PDF format by using MS Word itself. Could you please confirm if your document is not corrupted.?

Best Regards,

Hi Hafeez,

Thanks for your reply!!!
I am able to open this document in MS Word 2003(not tried in MS word 2007) and its not corrupted.
And also I am able to convert this document to pdf using latest version of Aspose.Word.
Here I am attaching xps of both word document as well as of converted pdf.
You can see below block is shifted to up-

“Licenza di circolazione
Attestato di assicurazione
Modulo di cancellazione del codice 178
Modulo di iscrizione del codice 178
Busta di risposta”

and other text also shifted slightly but not acceptable.
I hope this info will help you. Please let me know in case you need more info.
would be please to hear you soon.

Regards,
Sahil Kumar

Hi Hafeez,

Any updates on this. This is an production issue so pls look into this asap.

Thanks,
Sahil Kumar

Hi Sahil,

Thanks for the additional information.

While using the latest version of Aspose.Words i.e. 11.5.0, I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system. The issue ID is WORDSNET-6630. Your request has been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Moreover, I have attached both the XPS files, i.e generated on my side, here for your reference.

Best Regards,

1 Like

I am facing a similar issue. Has WORDSNET-6630 been fixed yet? I checked the Release Notes for the past few builds but I don’t see it listed.
Thanks

Hi Tim,

Thanks for your inquiry. I have verified the status of WORDSNET-6630 from our issue tracking system and regret to share with you that this issues has been postponed till a later date. I am afraid, we cannot push this into production right now because there are many other important issues we have to work on. Rest assured, we will inform you as soon as this issue is resolved. Sorry for the inconvenience.

Best Regards,

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

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