0

I want to read a PDF file as a string.
I'm using File.ReadAllText(path), but the result ends on the first stream of binary data.
I think it recognizes some part of the stream as the end of file and stops.

Any idea how to solve this?

2
  • You can extract text from a PDF using tools as IText7 Commented May 24, 2022 at 11:20
  • Does this answer your question? Base64 Encode a PDF in C#? Commented May 24, 2022 at 13:34

1 Answer 1

1

You cannot read a PDF file as a string, because a PDF file contains other data than just characters. Read the file into a byte array or parse it switching between reading text and binary data whenever you encounter a stream object in the PDF file.

Some languages like PHP treat strings and byte arrays as interchangeable. That is not the case in C#.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.