Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri May 08, 2020 11:27 am

Hi,
when I want to extract Text of a PDF-document using which has the PDFA/1 Standard there is an System.NullReferenceException.

I use the following code:

Code: Select all
if (document.Pages.Count > 0)
            {
                PdfPageBase page = document.Pages[0];
                string text = page.ExtractText();
                //int length = page.ExtractText().Length;
                if (text == null)
                {
                    return 0;
                }
                else
                {
                    return text.Length;
                }



Do you have any idea?

Thank you.

Kind Regards,

Jan Brandenburger

Can you please remove the attached file after read this post?

Jan.Brandenburger
 
Posts: 5
Joined: Tue Jun 26, 2018 5:52 am

Sat May 09, 2020 7:32 am

Hello,

Thanks for your inquiry.
I tested your scenario and indeed got the same exception. Our Dev team will adjust the internal code to get rid of this exception. If it is updated, we will let you know. However, after analysis, we found that there is no unicode encoding in your PDF document. Even using Adobe to extract directly, the extraction result also is empty. Sorry there is no better way to extract the text from your document. Hope you can understand.
Besides, we already removed your file from this post. Don’t worry, we will absolutely keep your documents confidential and won’t use them for other purpose.

Sincerely,
Sara
E-iceblue support team
User avatar

Sara.Yang
 
Posts: 33
Joined: Wed May 06, 2020 1:05 am

Wed May 13, 2020 5:02 am

Sara.Yang wrote:Hello,

Thanks for your inquiry.
I tested your scenario and indeed got the same exception. Our Dev team will adjust the internal code to get rid of this exception. If it is updated, we will let you know. However, after analysis, we found that there is no unicode encoding in your PDF document. Even using Adobe to extract directly, the extraction result also is empty. Sorry there is no better way to extract the text from your document. Hope you can understand.
Besides, we already removed your file from this post. Don’t worry, we will absolutely keep your documents confidential and won’t use them for other purpose.

Sincerely,
Sara
E-iceblue support team


Hi Sara,
sorry that I didn´t test the pdf-file with Adobe Acrobat... This is a useful hint.

I have to check why there is no content in this file. I had the idea it could be the watermark text in the background...

Best Regards,
Jan

Jan.Brandenburger
 
Posts: 5
Joined: Tue Jun 26, 2018 5:52 am

Wed May 13, 2020 7:06 am

Hello,

Thanks for your reply.
Your document does have text content, you can verify it with Foxit PDF Editor. As mentioned before, after our development analysis, your PDF document lacks unicode encoding, this caused the text can not be extracted. Maybe you need to adjust your document according to the PDF specification. If you have any other question, please feel free to contact us.

Sincerely,
Sara
E-iceblue support team
User avatar

Sara.Yang
 
Posts: 33
Joined: Wed May 06, 2020 1:05 am

Wed May 20, 2020 11:21 am

Sara.Yang wrote:Hello,

Thanks for your reply.
Your document does have text content, you can verify it with Foxit PDF Editor. As mentioned before, after our development analysis, your PDF document lacks unicode encoding, this caused the text can not be extracted. Maybe you need to adjust your document according to the PDF specification. If you have any other question, please feel free to contact us.

Sincerely,
Sara
E-iceblue support team


Hi Sara,
i downloaded the latest release where you have mentioned that you have fixed the NullReferenceException when extract text (SPIREPDF-3232).

But there is already an NullReferenceException.

I attached the pdf file again.

Kind Regards.

Jan

Jan.Brandenburger
 
Posts: 5
Joined: Tue Jun 26, 2018 5:52 am

Thu May 21, 2020 2:09 am

Hello,

Thanks for your feedback.
Kindly note that the fixing of "SPIREPDF-3232" is for other different documents. At present, the latest Spire.PDF version does not include a fix for your problem. The ticket of your issue is SPIREPDF-3252. However, I got the news from our Dev team that your problem has been solved and is in the testing phase now. Once the test is passed, we will provide you with a new version.

Sincerely,
Sara
E-iceblue support team
User avatar

Sara.Yang
 
Posts: 33
Joined: Wed May 06, 2020 1:05 am

Fri May 29, 2020 2:39 am

Hello,

Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:6.5.15. As for your issue of SPIREPDF-3252, our Dev team made some adjustments and fixing, now it does not throw exception and can extract the text content of your document, the attachment("ExtractText.txt") is my testing result for your reference. Please download it from the following links to test.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/

Sincerely,
Sara
E-iceblue support team
User avatar

Sara.Yang
 
Posts: 33
Joined: Wed May 06, 2020 1:05 am

Return to Spire.PDF