Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve text from some PDF documents #796

Open
securigy opened this issue Mar 15, 2024 · 1 comment
Open

Unable to retrieve text from some PDF documents #796

securigy opened this issue Mar 15, 2024 · 1 comment

Comments

@securigy
Copy link

I am using the library for a while now. However, today I noticed that if I save the content on the web as PDF using Microsoft PDF driver (that is, printing to PDF) then the code is unable to retrieve the text.
Here is one of such examples that I print to PDF:
https://healingthebody.ca/4-natural-proven-cancer-remedies/

and here is the code:

         `using (PdfDocument document = PdfDocument.Open(fileStream))
          {
                PdfDocInfo pdfDocInfo = new PdfDocInfo()
                {
                    DocFilePath = fileName,
                    TotalPages = document.NumberOfPages,
                    Version = document.Version,
                    Title = document.Information.Title,
                    Subject = document.Information.Subject,
                    Author = document.Information.Author,
                    DateCreated = dateCreated,
                    DateModified = dateModified,
                };

                string docText = "";
                string pattern = @"(?<=['""A-Za-z0-9][\.\!\?])\s+(?=[A-Z])";
                    
                foreach (Page page in document.GetPages())
                {
                    docText += ContentOrderTextExtractor.GetText(page, true);
                }

               // At this point docText is empty because each page delivers empty string through this GetText API`
         }

Any remedy for this?

@BobLd
Copy link
Collaborator

BobLd commented Apr 14, 2024

@securigy can you provide the exact pdf you used (generated from the html page I assume)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants