char* CosStringValue(CosObj obj, ASTCount* nBytes)
- CosStringValue may not return a C-String.
- The data pointed to by the returned pointer may contain embedded null bytes.
- The memory location used by CosStringValue can be reused at any time.
More recent versions of the Adobe Acrobat SDK / Adobe PDF Library have additional calls which can be used instead of CosStringValue which are much safer to work with in general use:
char* CosCopyStringValue(CosObj obj, ASTCount* nBytes) char* CosStringValueSafe(CosObj obj, char* buffer, ASTArraySize bufferSize, ASTCount* nBytes)
Note: The pointer returned from this method is not guaranteed to remain valid if CosStringValue() is called again. It is recommended that you use CosStringValueSafe() or CosCopyStringValue() instead; these methods place the string into a user-allocated buffer.
Note: The caller must immediately copy the returned string. The memory pointed to be the return value may become invalid if any memory-allocating calls are made. In particular, consider the sequence:
str1 = CosStringValue(...); str2 = CosStringValue(...);
In this case, the contents of str1 may be invalid by the time the second CosStringValue() call returns.
Note: The returned value is not a C-style string. Cos string objects can contain NULL bytes. Standard C string-handling functions may not work as expected.