I don’t do much with PDF, but I notice you say that the whole file is scrambled unless you disable compression? that sounds like a red flag for text encoding issues. Are you using the module’s own function for reading and writing files? or did you maybe load the file yourself with the wrong binmode or encoding applied? Likewise for saving.