Am 14.09.2010 09:41, schrieb Timo Boehme:
Hi,

I'm not sure if it is resonable to mix up COSNames with a special
meaning and
simple COSStrings. Can you explain what exactly your are trying to do?

I will give you an example. When I want to read the alternate color
space name of a DeviceN color space I have to write something like

public String getAlternateColorSpaceName()
{
COSBase alternate = array.getObject( 2 );
if ( alternate instanceof COSName )
return ((COSName) alternate).getName();
else if ( alternate instanceof COSString )
return ((COSString) alternate).getString();
else if ( alternate instanceof COSArray ) {
COSArray altCsArr = (COSArray) alternate;
String csName = altCsArr.getName(0);
if ( csName == null )
// maybe a string object
csName = altCsArr.getString(0);
return csName;
}

log.error( "Unexpected object type for alternate color
space name: " + alternate.getClass().getSimpleName() );

return "";
}

It might be the case that normally such names should be COSName objects
but most objects (color space objects etc.) allow the user to set such
names while creating/manipulating a PDF document and typically accept a
COSBase object. Thus the user might add the name as a COSString.
AFAIU the pdf specs, the "alternateColorspaces" array of a DeviceN colorspace should only contain COSName objects. Do you have an example with COSStrings instead of COSNames?

BR
Andreas Lehmkühler

Reply via email to