Complete untested refactor of pdf-view.js

Checkin on branch prior to testing.
Fix a number of bugs in pdf refactor

Also includes a fair amount of debugging output that will need to
be removed before merging to master.