Hi GemBox Team,
I am using GemBox.Document in version 2026.3.103 and I am receiving the following NullReferenceException when saving a DocumentModel to PDF:
System.NullReferenceException: Object reference not set to an instance of an object.
at .(String , , , , )
at .(String , , , , )
at .(F )
at .( , , , )
at .( , , )
at .( , , )
at .( , , )
at A.( , )
at .(A , )
at A.( , )
at A.( , )
at A.( )
at .( , , , , , )
at .( , [] , , , )
at .( , Int32 , , , , )
at .( , , Int32 )
at .(Int32 , Object , Object )
at GemBox.Document.DocumentModelPaginator.dca75czcds9lmgv2y95q5srjljs9plta(Int32 , Object , Object )
at .Write( , String , Stream )
at .( , , Stream )
at GemBox.Document.PdfSaveOptions.( , Stream )
at GemBox.Document.PdfSaveOptions.( , Stream )
at .( , , Boolean , Stream )
at GemBox.Document.PdfSaveOptions.Save( , Stream )
at GemBox.Document.PdfSaveOptions.Save(DocumentModel , Stream , String )
at GemBox.Document.SaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8(DocumentModel , Stream , String , Boolean )
at GemBox.Document.DocumentModel.Save(String path, SaveOptions options)
at GemBox.Document.DocumentModel.Save(String path)
at DMSHangfire.Services.Files.FileConversionService.ConvertDocumentToPdf(String sourceFilePath, String pdfDestFile, ...)
The code being used is:
csharp
var document = DocumentModel.Load(sourceFilePath);
document.Save(pdfDestFile);
Some important observations:
-
DocumentModel.Load()succeeds without error — the document opens fine -
The exception occurs during
DocumentModel.Save()insideDocumentModelPaginatorwhen rendering to PDF -
It does not occur with every
.docxfile, only specific ones -
The affected documents are valid and not corrupt — Microsoft Word’s built-in PDF export handles them correctly without issue
I can provide the problematic .docx files on request. Please could you investigate?
Kind regards,
Rob Thornley