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

Free Support Forum - aspose.com

textFragment.Text null exception

Hi, I’m getting an exception when I try to replace a simple text on a small PDF.
This is the error:

Object reference not set to an instance of an object.

This is the code i’m using:

        // Open document
        Document pdfDocument = new Document(Server.MapPath(@"\test\Test1_compress.pdf"));

        // Create TextAbsorber object to find all instances of the input search phrase
        TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("UserName");
        // Accept the absorber for all the pages
        // Get the extracted text fragments
        TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

        // Loop through the fragments
        foreach (TextFragment textFragment in textFragmentCollection) {
            textFragment.TextState.FontSize = 30;
            textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
            textFragment.Text = "CarlosJCT";

The error is in the line:
textFragment.Text = “CarlosJCT”;Test1_compress.pdf (68.7 KB)


We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51081. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thanks for the response, we are evaluating and will buy a PDF license if we can do the following:
Open a PDF (template)
Replace some images (this can be index base replacement), I try this and is working.
Replace text placeholders (without alter the design)
Export the pdf.

We may need some other things but that is the most important things we need.


With Aspose.PDF, you can achieve your shared requirement. Regarding PDFNET-51081, we will inform you via this forum thread once there is an update available on it.

Hi, how is everything? what is the status of this bug? let us know, we are ready to make a purchase as soon as everything is working fine, thanks.


Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

Hi, any news about this issue? we are looking other options but just let me know if you still looking on this bug, thanks.


Unfortunately, there is no update available on your issue at the moment. We will be sure to inform you via this forum thread once there is any news available.