GemBox.Document 2026.3.103 - NullReferenceException in DocumentModelPaginator when saving specific .docx files to PDF

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() inside DocumentModelPaginator when rendering to PDF

  • It does not occur with every .docx file, 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

Hi Rob,

Please try again with this NuGet package:

Install-Package GemBox.Document -Version 2026.4.111

Note that this is a hidden (unlisted) version. To install it, you’ll need to run the above command on the NuGet Package Manager Console (Tools → NuGet Package Manager → Package Manager Console).

Does this solve your issue?

Regards,
Mario