We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

System.InvalidCastException is thrown while saving DOCX to PDF using .NET

Greetings,

I get the following exception when saving the attached sample Word document Issue.zip (17.0 KB) as PDF with revision balloons using Aspose.Words for .NET 20.2.0 :

System.InvalidCastException: ‘Unable to cast object of type ‘Aspose.Words.HeaderFooter’ to type ‘Aspose.Words.Body’.’

using the following C# code to reproduce :

var doc = new Document(path);

doc.LayoutOptions.RevisionOptions.ShowInBalloons = Aspose.Words.Layout.ShowInBalloons.FormatAndDelete;

doc.Save(doc.OriginalFileName + ".pdf", SaveFormat.Pdf);

@skirov

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-20039. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

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