prawnpdf/prawn — pull request #468 by krishicks (2013-04-01 16:49:46+00:00)
Title: Add more thorough searching for :MediaBox entry

This is a solution, though perhaps not the best one, for this issue in prawnpdf/prawn: https://github.com/prawnpdf/prawn/issues/386

I think it might be relevant to change the search in document.state.store to be the following:

```diff
def media_box
if dictionary.data.has_key?(:MediaBox)
dictionary.data[:MediaBox]
else
-- document.state.store.detect { |ref|
++ document.state.store.to_a.reverse.detect { |ref|
ref.data.has_key?(:MediaBox)
}.data[:MediaBox]
end
end
```

But I think that would only matter if you want to search the previous pages in the order they were added (if my understanding of how ObjectStore works is correct).

I'm happy to take suggestions or a full rewrite from someone that knows the internals of Prawn better.

Cheers.