NullReferenceException converting to PDF

Hi we’ve implemented a system using aspose.


A user can upload a document into the system which recreates the document’s headers and footers, Other users can then view the document in PDF format. There are thousands of documents in the system, most of these seem to be fine.

For a specific document, after the header and footer is regenerated (using Aspose), when we try and convert that document to PDF (with Aspose) we get a null reference exception.

Call stack is as follows…

System.NullReferenceException: Object reference not set to an instance of an object.
Result StackTrace:
at .(Single , Border )
at .(RectangleF , Border , Border , Border , Border )
at .(RectangleF , Border , Border , Border , Border )
at .( )
at .( , ? , Boolean )
at .( , ? , Boolean )
at .( , Boolean )
at ? .( , Boolean& )
at ? .( , Boolean& )
at ? .(? )
at ? .()
at ? .? ? ()
at ? .? ? ()
at ? .? ? ()
at ? .()
at ? .(? , Int32 )
at ? .(? )
at ? .(? )
at ? .(? , Int32 )
at .( , Int32 , Boolean )
at ? .()
at ? .(? , Int32 , Boolean , Boolean )
at . ()
at .( , Int32 )
at .( )
at .()
at .( )
at .(? )
at .(Boolean )
at .(Boolean )
at . ()
at .(Document , )
at Aspose.Words.Document.UpdatePageLayout()
at . ? ()
at ? .( )
at .( , )
at .(Node , )
at .(Node )
at Aspose.Words.Document.()
at Aspose.Words.Document.(Stream , String , SaveOptions )
at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions)
at Aspose.Words.Document.Save(Stream stream, SaveFormat saveFormat)
at Tonic.Documents.DocumentAsposeOperations.WriteDocumentFile(Stream outputStream, String sourceFilePath, String destFileName, Boolean controlled) in s:\Tonic.Documents\DocumentAsposeOperations.cs:line 124
at Tonic.Sonic.Data.Test.Documents.DocumentFileOperationTests.TestConvertPDF() in d:\Projects\Documents\DocumentFileOperationTests.cs:line 82

The code to convert the document to PDF is …

public bool WriteDocumentFile(Stream outputStream, string sourceFilePath, string destFileName, bool controlled)
{
// the destination has a PDF extension
Document wordDocument = new Document(sourceFilePath);
if (controlled)
{
        // Controlled is false
    }
    var format = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(destFileName).SaveFormat;
if (format == SaveFormat.Unknown)
format = GetSaveFormat(sourceFilePath);
wordDocument.Save(outputStream, format);  // NULL reference Exception here

    return true;
}
I’ve attached the file causing the issue, this is the file after it has had it’s headers
and footers recreated using Aspose.

If you open this file in Word, save it, then attempt to convert it to PDF again,
you do not get the error.

Hi John,

Thanks for reporting this issue to us.

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

Best regards,

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


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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan