refactor pdf controller