Free Support Forum - aspose.com

Document.updatePageLayout throws Null pointer exception using Java

Hello,

I’m getting an NullPointerException when calling Document.updatePageLayout().

When I then try to call Document.save() I get an IllegalArgumentException.

If I leave out the updatePageLayout() everything works fine.

Please find both stack traces below.

Thanks for your support!
Dirk Steinkamp


java.lang.NullPointerException

at com.aspose.words.zzYV6.zzYCr(Unknown Source)

at com.aspose.words.zzZJO.zzL(Unknown Source)

at com.aspose.words.zzZJO.zzZX(Unknown Source)

at com.aspose.words.zzZJN.zzZ(Unknown Source)

at com.aspose.words.zzZJN.zzM(Unknown Source)

at com.aspose.words.zzZJX.zzI(Unknown Source)

at com.aspose.words.zzZJW.zzD(Unknown Source)

at com.aspose.words.zzZJW.zzU(Unknown Source)

at com.aspose.words.zzZJW.zzV(Unknown Source)

at com.aspose.words.zzW7.zzZ(Unknown Source)

at com.aspose.words.zzW7.zzZ(Unknown Source)

at com.aspose.words.zzYW5.zzYDc(Unknown Source)

at com.aspose.words.zzYW5.zzY(Unknown Source)

at com.aspose.words.zzYW5.zzZ(Unknown Source)

at com.aspose.words.zzGX.zzY(Unknown Source)

at com.aspose.words.zzGX.zzN(Unknown Source)

at com.aspose.words.zzW7.zzZ(Unknown Source)

at com.aspose.words.zzW7.zzZ(Unknown Source)

at com.aspose.words.zzYW5.zzYDc(Unknown Source)

at com.aspose.words.zzYW5.zzY(Unknown Source)

at com.aspose.words.zzYW5.zzZ(Unknown Source)

at com.aspose.words.zzXP.zzc2(Unknown Source)

at com.aspose.words.zzXP.zzW(Unknown Source)

at com.aspose.words.zzXP.zzX(Unknown Source)

at com.aspose.words.zzZ5F.zzF(Unknown Source)

at com.aspose.words.zzZ5F.zzG(Unknown Source)

at com.aspose.words.zzZ5F.zzYS3(Unknown Source)

at com.aspose.words.zzZ5F.zzN(Unknown Source)

at com.aspose.words.zzZ4Q.zzG(Unknown Source)

at com.aspose.words.zzYU9.zz9(Unknown Source)

at com.aspose.words.zz8N.zzG(Unknown Source)

at com.aspose.words.zz8O.zzZG5(Unknown Source)

at com.aspose.words.zzZ5M.zzYSm(Unknown Source)

at com.aspose.words.Document.updatePageLayout(Unknown Source)

at de.isd_service.koko.tools.office.word.KokoWordDocAsposeImpl.updateAllFieldReferences(KokoWordDocAsposeImpl.java:1646)

at de.isd_service.koko.merger.word.WordMerger.afterAllRecords(WordMerger.java:270)

at de.isd_service.koko.merger.Merger.processRows(Merger.java:336)

at de.isd_service.koko.merger.word.WordSingleRecordMerger.processRows(WordSingleRecordMerger.java:39)

at de.isd_service.koko.merger.multi.MultiBriefMerger.processRowsAndGenerateOutput(MultiBriefMerger.java:215)

at de.isd_service.koko.main.KokoWorker.doWork(KokoWorker.java:97)

at de.isd_service.koko.main.KokoWorker$1.run(KokoWorker.java:197)

at de.isd_service.koko.main.KokoWorker.startWorkAndReturnToPool(KokoWorker.java:215)

at de.isd_service.koko.main.MainClassic.processArgs(MainClassic.java:275)

at de.isd_service.koko.main.MainClassic.main(MainClassic.java:138)

Specified argument was out of the range of valid values.

Parameter name: pageIndex

java.lang.IllegalArgumentException: Specified argument was out of the range of valid values.

Parameter name: pageIndex

at com.aspose.words.Document.zzYf(Unknown Source)

at com.aspose.words.zzZZQ.zzY(Unknown Source)

at com.aspose.words.zzZZQ.zzZ(Unknown Source)

at com.aspose.words.zzZF2.zzZ(Unknown Source)

at com.aspose.words.Document.zzZ(Unknown Source)

at com.aspose.words.Document.zzZ(Unknown Source)

at com.aspose.words.Document.save(Unknown Source)

at de.isd_service.koko.tools.office.word.KokoWordDocAsposeImpl.exportPDF(KokoWordDocAsposeImpl.java:159)

at de.isd_service.koko.merger.word.WordMerger.pdf(WordMerger.java:358)

at de.isd_service.koko.merger.Merger.pdf4Dms(Merger.java:936)

at de.isd_service.koko.merger.multi.MultiBriefMerger.pdf4Dms(MultiBriefMerger.java:116)

at de.isd_service.koko.merger.Merger.saveToDms(Merger.java:678)

at de.isd_service.koko.merger.multi.MultiBriefMerger.saveToDms(MultiBriefMerger.java:322)

at de.isd_service.koko.merger.Merger.saveToDmsIfAllowedAndCheckSuccess(Merger.java:598)

at de.isd_service.koko.merger.Merger.doOutput(Merger.java:542)

at de.isd_service.koko.merger.multi.MultiBriefMerger.processRowsAndGenerateOutput(MultiBriefMerger.java:243)

at de.isd_service.koko.main.KokoWorker.doWork(KokoWorker.java:97)

at de.isd_service.koko.main.KokoWorker$1.run(KokoWorker.java:197)

at de.isd_service.koko.main.KokoWorker.startWorkAndReturnToPool(KokoWorker.java:215)

at de.isd_service.koko.main.MainClassic.processArgs(MainClassic.java:275)

at de.isd_service.koko.main.MainClassic.main(MainClassic.java:138)

@Dirk_Steinkamp

Could you please attach your input Word document here for testing? We will investigate the issue on our side and provide you more information.

Thanks for your reply!

I’ve been trying to create a reproducible error from the document. Unfortunately with no success so far. The error only occurs sometimes after my program has done a bunch of modifications on the template document – and if I try to save the document right before calling the update as a docx and then reopen it in a unit test the error doesn’t occur again.
Do you have any hint how to save the internal document representation in a way that will preserve “everything”, so I get a pinned down situation for a reproducible test case?

@Dirk_Steinkamp

It is difficult to say what the problem is without document. Could you please share complete detail of your use case? Moreover, we need your document for testing. Thank for your cooperation.