The qpdf documentation states that it is possible to remove an object then run fix-qdf and it should renumber the remaining objects. In an exemplary PDF, I did this: - qpdf --qdf dings.pdf dings.qdf - $EDITOR dings.qdf - remove object '38 0' and the one reference to it - fix-qdf dings.qdf >dings2.qdf It complained about the missing object: dings.qdf:20254: expected object 38 Line 20254 here is exactly the beginning of object '39 0' after the end of object '37 0'. ──┤ Workaround ├──────────────────────────────────────────────────────── Just removing all the references and letting qpdf clean up the now-unreferenced object seems to have worked here. But this does still not work as documented…
Can you tell me where in the docs it says what you're describing? Here's a direct quote from the current qpdf documentation: It is not generally practical to remove objects from QDF files without messing up object numbering, but if you remove all references to an object, you can run qpdf on the file (after running fix-qdf), and qpdf will omit the now-orphaned object. To me, it seems that the documentation matches the observed and intended behavior. Maybe there was an error in the older docs that have been subsequently fixed.
Jay Berkenbilt dixit: Yes, I meant that. At least two people assumed that “remove all references” includes the object itself, but now that you point it out, it likely doesn’t, but we are no native speakers, so I don’t know which of the two interpretations is more likely to them or if even both are possible. Maybe, if you have good connections to upstream, suggest to them to add “(but not the object itself)” to behind “all references to an object”, but the bug can then be closed. Thanks for looking into it, //mirabilos
Sorry for the top-post. As it happens, I am upstream. I have rewritten the pargraph as follows. I think this is clearer. What do you think? If you like it, I'll close this. My fix is here: https://github.com/qpdf/qpdf/pull/1187--- It is not generally practical to remove objects from QDF files without messing up object numbering, but if you remove all indirect references to an object (without removing the object itself), this will leave the object unreferenced. Then you can run qpdf on the file (after running :command:`fix-qdf`), and qpdf will omit the now-orphaned object. ---
Jay Berkenbilt dixit: Oh, nice ☻ in that case, thanks for qpdf. That fixes the ambiguity but leaves the reader¹ wondering, on two reading passes, what other references than indirect there are. The reader who has not digested the PDF spec in and out, at least. If you s/ indirect//, would it still be correct? That would be less possibly-ambiguous, I think. bye, //mirabilos ① or at least me right now
(Sorry for the duplicate -- I inadvertently failed to cc the bug report on my private reply.) If it triggers this thought in you, it will trigger it in others. New wording: It is not generally practical to remove objects from QDF files without messing up object numbering, but if you remove all references to an object without removing the object itself (by removing all indirect objects that point to it), this will leave the object unreferenced. Then you can run qpdf on the file (after running :command:`fix-qdf`), and qpdf will omit the now-orphaned object.
Jay Berkenbilt dixit: That explains it very well and not ambiguous to nōn-native speakers (I hope). Thanks, //mirabilos