ReadStream
ReadStream object provides access to data streams for reading embedded file contents and other stream data within PDF files. The stream reads data as hexadecimal-encoded strings.
methods
read
Secure |
---|
No |
Reads bytes from the stream and returns them as a hexadecimal-encoded string.
read(nBytes)
nBytes: Number of bytes to read from the stream
Returns a hexadecimal-encoded string representing the bytes read. Each byte is represented by two hexadecimal characters. If the end of the stream is reached, the stream is automatically closed and subsequent calls will return an empty string.
example:
// Read an embedded text file
var stream = this.getDataObjectContents("data.txt")
var hexData = stream.read(100) // Read first 100 bytes as hex string
console.println(hexData)
// Convert entire stream to string using util helper
var stream2 = this.getDataObjectContents("data.txt")
var text = util.stringFromStream(stream2, "utf-8")
console.println(text)