Mon Jan 30 23:02:03 2017 steve [...] deefs.net - Correspondence added
Ok, here are a couple of things to try:
1) I just released PDF::API2 version 2.031. It has some fixes that could potentially impact this bug.
2) Is the problem reproducible on a given PDF? In other words, on the 1% or so that fail, do they keep failing if you re-run the script?
Given that you're seeing the numbers 500 and 1000 show up, I'm going to guess that the problem *is* reproducible on a given file, and that the affected PDFs have object streams in them, based on a bug I tracked down and fixed for a previous release. That's still relatively new code (added in 2.026), so there are probably still some edge cases that aren't working, which would explain why you're only seeing the problem occasionally.
If you can reproduce the problem on a given PDF that you can send to me privately for the sole purpose of troubleshooting this bug, I should be able to get a fix released.
-- Steve
PS: In regard to your other note, yes, the PDFNum wrapper function does need to be called so that the serializer knows what kind of value to write to the file (e.g. a literal number vs. a name, boolean, string, etc.)