final byte[] result;
switch (contentObject.type())
{
case PdfObject.INDIRECT:
final PRIndirectReference ref = (PRIndirectReference) contentObject;
final PdfObject directObject = PdfReader.getPdfObjectRelease(ref);
result = getContentBytesFromContentObject(directObject);
break;
case PdfObject.STREAM:
final PRStream stream = (PRStream) PdfReader.getPdfObjectRelease(contentObject);
result = PdfReader.getStreamBytes(stream);
break;
case PdfObject.ARRAY:
// Stitch together all content before calling processContent(), because
// processContent() resets state.
final ByteArrayOutputStream allBytes = new ByteArrayOutputStream();
final PdfArray contentArray = (PdfArray) contentObject;
final ListIterator<PdfObject> iter = contentArray.listIterator();
while (iter.hasNext())
{
final PdfObject element = iter.next();
allBytes.write(getContentBytesFromContentObject(element));
allBytes.write((byte)' ');
}
result = allBytes.toByteArray();
break;