PDF Output: Fix using __SECTION__ in header and footer templates resolving to the inscorrect section if a page with no sections follows a page with multiple sections. Fixes #1295236 [[Conversion HTML-> PDF] PDF header/footer uses wrong _SECTION_ when a single page contains more than one section](https://bugs.launchpad.net/calibre/+bug/1295236)