PDF: fix various hangs (cf. bug 695040)