Description
COSStreamArray checks whether array contains any items. If array is empty firstStream is not set and therefore null.
public COSStreamArray( COSArray array )
{
super( new COSDictionary(), null );
streams = array;
if( array.size() > 0 )
}
Most methods of COSStreamArray however use firstStream without any checks which can result in a NullPointerException.
I have a PDF that when parsed, results in a NPE because COSStreamArray#getScratchFile is called while firstStream is null.
One option would be to not create an instance of COSStreamArray when there are no items in the array.
A patch is attached that checks whether the array is empty and only creates an instance of there are any items.
The PDF was created with:
LaTeX with hyperref package
PDF-1.2