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

Free Support Forum - aspose.com

Aspose.Pdf.Text.TextBuilder constructor throws NullReferenceException

We have an application that appends text to PDF documents. Most of the time, everything works as expected.

For some PDF files, however, we have found that the Aspose.Pdf.Text.TextBuilder constructor throws a NullReferenceException.

I checked the PDF and it does not have any errors ( according to this tool https://www.pdf-online.com/osa/repair.aspx )

Attached is one of the PDFs that we cannot process.

Here is some sample code to reproduce the exception:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AsposePDFTest
class Program
static void Main(string[] args)
var pdfDocument = new Aspose.Pdf.Document(“Test.pdf”);
var page = pdfDocument.Pages[pdfDocument.Pages.Count];
var textBuilder = new Aspose.Pdf.Text.TextBuilder(page); // new TextBuilder(…) throws NullReferenceException

/// obfuscated stack trace

System.NullReferenceException: Object reference not set to an instance of an object.
at Œ.˜.˜(Operator )
at Œ.˜.Parse()
at Œ.š.(BaseOperatorCollection , Resources , Page )
at Œ.š.(BaseOperatorCollection , Resources )
at Œ.š.()
at Œ.š…ctor(Page , TextSearchOptions , Resources , BaseOperatorCollection , Boolean )
at Œ.š…ctor(Page , TextSearchOptions , Resources , BaseOperatorCollection )
at Œ.š…ctor(Page , BaseOperatorCollection )
at Aspose.Pdf.Text.TextBuilder…ctor(Page page)
at AsposePDFTest.Program.Main(String[] args) in c:\Users\RobertH\Documents\Visual Studio 2012\Projects\AsposePDFTest\AsposePDFTest\Program.cs:line 17

Hi there,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for .NET 9.5.0 and your source document, we have managed to reproduce the reported exception and logged it in our bug tracking system as PDFNEWNET-37379 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-37379) have been fixed in Aspose.Pdf for .NET 9.7.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.