Fix structural errors in PDF produced by CPDF (#517)