fix bug in pdf code