I’m encountering this exception when the program opens a particular .DOC file. Most other files open fine. This is the exception message:
System.NullReferenceException: Object reference not set to an instance of an object.
at .()
at ..ctor(Node , Boolean , Node , Boolean , BookmarkStart )
at .(Field , Bookmark , Boolean , Boolean& )
at Aspose.Words.Fields.FieldRef.86q6acmbfp2kjwdcs2q6rs3uwmqt2zc9 ()
at .(Field )
at .(Field )
at . ( )
at .( )
at .( )
at .( )
at .( , )
at .(Node , )
at .(Node )
at Aspose.Words.Document.()
at Aspose.Words.Document.( )
at Aspose.Words.Document.(Stream , String , SaveOptions )
at Aspose.Words.Document.Save(String fileName)
at APP-NAME.Utilities.PDFHelper.ConvertToPdf(String inputFile, String outputFile, Boolean needHeader, String leftHeader, String rightHeader, String docType) in C:\Users\username\Documents\APP-folder\APP-NAME\Utilities\PDFHelper.cs:line 42
This is all the code I’m using to open the document. It’s saving the .DOC as a .PDF:
try
{
Aspose.Words.Document doc = new Aspose.Words.Document(inputFile);
doc.AcceptAllRevisions();
doc.Save(outputFile);
}
catch(System.Exception ex)
{
WriteToErrorFile(errorFile, ex.ToString(), inputFile);
}
Any ideas?
Thanks!