NullReferenceException is thrown while saving DOCX to PDF using .NET

I need help.

I have troubles in converting the attached document. We applied the following code.

Aspose.Words.Document document = new Aspose.Words.Document(stream); Aspose.Words.Saving.PdfSaveOptions saveOption = new Aspose.Words.Saving.PdfSaveOptions() {
SaveFormat = Aspose.Words.SaveFormat.Pdf,
OutlineOptions = { HeadingsOutlineLevels = 9 }
};
document.Save(outputFilePath, saveOption);

Error:

  • System.NullReferenceException: Object reference not set to an instance of an object.

    at
    ? .

()

at .

()

at ? .[1]( [1], Int32

, Boolean , Boolean )

at
.
()

at
. ()

at
.

( [1], Int32

)

at
.[1]( [1], Int32

)

at ? .

( [1])

at ? .1

at ? .[1](? [1])

at .1

at

.1

at [1] .[1] ()

at .

()

at Aspose.Words.Document.UpdatePageLayout()

at ? . ? ? 1

at ? .

(?? [1])

at ?? .[1](?? [1], ??

)

at ?? .[1](Node [1], ??

)

at Aspose.Words.Document.()

at Aspose.Words.Document.[1]([1]? [1])

at Aspose.Words.Document.[1](Stream [1], String

, SaveOptions )

Attachment download:
doc error.zip (344.8 KB)

Thanks for support!

@federicogelpi

We have tested the scenario using the latest version of Aspose.Words for .NET 20.7 and have not found the shared issue. So, please Aspose.Words for .NET 20.7.

Hi @tahir.manzoor

I have updated the Aspose.Word component to version 20.7 but it continues to give me the same problem reported in my post. I try to attach the document that is going to exception again when I try to convert it from Word to PDF.

Can you kindly help me understand where the problem is in the document, for example is there some text format, incorrect table or revisions / comments that make the component go out of exception?

Attach:
document error.zip (232.3 KB)

Thanks for support!

@federicogelpi

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20886 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor

Thanks for the reply and for your support, can you kindly tell me what problem has the document I attached? I need to know if I can correct the document to resolve the component anomaly.

Thanks for support!

@federicogelpi

The issue you are facing is due to footnotes in the document. You can remove footnotes from the document to avoid this exception.

doc.GetChildNodes(NodeType.Footnote, true).Clear();

@tahir.manzoor

Thanks for the clarification, but sadly the footnotes are needed and I cannot remove them from the document. Does it have an indicative date when you will fix this bug?

I saw that 6 days ago Aspose.Words version 20.8 came out, does that version solve the above problem or is it still under development?

Thanks so much for the support

@federicogelpi

Your issue is related to another footnote issue (WORDSNET-18678). After the fix of this issue, we will look into your issue. We regret to share with you that your issue has been postponed (no estimate is available at the moment). We will inform you via this thread as soon as this issue is resolved.

We apologize for your inconvenience.

A post was split to a new topic: NullReferenceException is thrown when DOCX is saved to PDF

The issues you have found earlier (filed as WORDSNET-20886) have been fixed in this Aspose.Words for .NET 20.10 update and this Aspose.Words for Java 20.10 update.