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?
CodePudding user response:
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#.