modified to output pdf vice png