I had the same issue on a form that I was working on. I had one button that would extract the first page - this.extractPages(0) - worked great.
Everytime I took the same code and placed in a second button and changed it to extract the last page - this.extractPages(1) I would get this error
I went in and deleted all tags that were in the document. Poof it worked. At least it fixed my issue
Adobe Pro XI