PRD-4594 and PRD-4596: PDF export fixes

and cleanups