handle stream length being an object stream value

This commit is contained in:
Eliot Jones
2019-12-24 15:22:47 +00:00
parent 9c9a08c6a7
commit 23c7e44fc8

View File

@@ -535,6 +535,18 @@
// We can only find it if we know where it is. // We can only find it if we know where it is.
if (objectLocationProvider.TryGetOffset(lengthReference.Data, out var offset)) if (objectLocationProvider.TryGetOffset(lengthReference.Data, out var offset))
{ {
if (offset < 0)
{
var result = GetObjectFromStream(lengthReference.Data, offset);
if (!(result.Data is NumericToken streamLengthToken))
{
throw new PdfDocumentFormatException($"Could not locate the length object with offset {offset} which should have been in a stream." +
$" Found: {result.Data}.");
}
return streamLengthToken.Long;
}
// Move to the length object and read it. // Move to the length object and read it.
Seek(offset); Seek(offset);