I have opened a portfolio and are trying to retrieve information from it by position, the problem is the PDCollectionSchemaGetField routine below is crashing acrobat. I have tried different index positions e.g. 0, 1 etc. any ideas? I have tried different pdf's also. thanks. lee.
The (sz) schema length is: 12
It's says in the documentation:- ASBool PDCollectionSchemaGetField(PDCollectionSchema schema, PDCollectionFieldRec* field) Gets a field by name or position. The caller must set field.size to sizeof(PDCollectionFieldRec). To look up a field by name, set field.fieldName to the appropriate name. To look up a field by position, set field.fieldName to ASAtomNull, and set field.index to the position. The caller owns (and must destroy) field.fieldText if it is not NULL.
my code:-
if(PDCollectionIsValid(pdCollect))
{
PDCollectionSchema schema = PDCollectionSchemaAcquire(pdCollect);
if(schema)
{
ASArraySize sz = PDCollectionSchemaGetLength(schema);
char msg[255] = { '\0' };
sprintf(msg,"schema size: %ld",sz);
AVAlertNote(msg);
PDCollectionFieldRec recSchemaField;
recSchemaField.size = sizeof(PDCollectionFieldRec);
recSchemaField.fieldName = ASAtomNull;
recSchemaField.index = 0;
AVAlertNote("PDCollectionSchemaGetField");
ASBool rt = false;
DURING
rt = PDCollectionSchemaGetField(schema, &recSchemaField); // crashes acrobat here!
HANDLER
char errorMsg[255] = { '\0' };
ASInt32 myException = ASGetExceptionErrorCode ();
ASGetErrorString ( myException, errorMsg, 256);
AVAlertNote ( errorMsg);
return;
END_HANDLER
AVAlertNote("PDCollectionSchemaGetField ran ok");