Welcome to the ASP.NET Core feedback portal. We’re happy you’re here! If you have feedback on how to improve the ASP.NET Core, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

        FileStream inputDocument = new FileStream(filePath, FileMode.Open);

        PdfLoadedDocument loadedDocument = null;

        StringBuilder sb = new StringBuilder();

        try

        {

            loadedDocument = new PdfLoadedDocument(inputDocument);

           for (int pageIndex = startPageIndex - 1; pageIndex <= endPageIndex; pageIndex++)

            {

                sb.Append(loadedDocument.Pages[pageIndex].ExtractText(true));

            }

            loadedDocument.Close(true);

        }

        catch (Exception exc)

        {

            this.logger.LogError(exc.Message);

            return string.Empty;

        }


 return sb.ToString();


It puts spaces where there should be no spaces when converting PDF to text. It also connects the places where there should be spaces.

This is the part of pdf:

pdfsample.jpg


This is the result text:

Empty