Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Find Text in Pdf Error

$
0
0
I have an issue when using the TextFragmentAbsorber.
First let me describe the bigger picture.

I have an HTML view.
I generate a PDF file from it using HTML to Pdf conversion.
I temporarily save the file before returning it to the client.

Then I am trying to insert a form input on a certain location in the PDF file.
That location can be found by searching for "[textinput]" in the PDF.

To do that, I use the following code:

Document document = new Document(pdfFilePath);
//the file path is correct and the Document is initialised succesfully
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("[textinput]");

//here I get an error - "Object reference not set to an instance of an object."
document.Pages.Accept(textFragmentAbsorber);


So what am I doing wrong? Please help me if you know a fix.

I forgot to specify: The PDF file HAS content. So it's not empty. The algorythm just crashes.

I made it work on a dummy test pdf file.
 I will look again maybe it's my fault in dealing with the PDF file.

I still get the error on a sepcific pdf file. I thought it shouldn't care about the content.
I attached the file. I tested it and it crashes at the line of code I specified.

Viewing all articles
Browse latest Browse all 3131

Trending Articles