Refactor pdf call