An issue when extracting raw data from page content stream.

Q: The GetAt() method on an object returned by getSDFObj().FindObj()
seems to work file in JAVA but returns the following exception in C#:

+ ex {\"Exception: \\n\\t Message: GetAt() can\'t be invoked on Obj
of this type.\\n\\t Conditional expression: false\\n\\t Filename :
Obj.cpp\\n\\t Function : trn::SDF::Obj::IllegalFunctionException\\n\
\t Linenumber : 132\\n\"} System.Exception
{pdftron.Common.PDFNetException}

FEATURE DETAILS:
Obj pageContents = doc.getPage(1).getSDFObj().findObj(\"Contents\");

//The first thing to do is to grab the page object contents, decode
all those streams, concatenate them
//in pageContentsStream, do some replacements in the string, then put
that object back into the pdf
int sz = (int)pageContents.size();
for (int i=0; i < sz; i++) {
  FilterReader reader = new
FilterReader(pageContents.getAt(i).getDecodedStream());
  ByteArrayOutputStream g = new ByteArrayOutputStream(); //equivalent
of C# MemoryStream
  g.write(reader.read(1024*1024)); //read one MB of each stream.
Should be enough to read the entire stream.
  pageContentsStream += g.toString();
}
------------------------------
A: You should get exactly the same results if you are working on same
file, so most likely you are processing different files.

The problem is that your code assumes that page contents is always an
array. However pageContents could also be a single stream object. As a
result you need to check if pageContents is a stream or an array.