#1067196 qpdf: contrary to the documentation, fix-qdf aborts on removed objects

Package:
qpdf
Source:
qpdf
Description:
tools for transforming and inspecting PDF files
Submitter:
Thorsten Glaser
Date:
2024-04-29 05:24:03 UTC
Severity:
normal
Tags:
#1067196#5
Date:
2024-03-19 21:14:28 UTC
From:
To:
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…

#1067196#10
Date:
2024-04-06 21:56:15 UTC
From:
To:
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.

#1067196#15
Date:
2024-04-07 09:04:01 UTC
From:
To:
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

#1067196#20
Date:
2024-04-13 23:24:14 UTC
From:
To:
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. ---
#1067196#25
Date:
2024-04-14 17:50:19 UTC
From:
To:
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

#1067196#30
Date:
2024-04-28 18:51:40 UTC
From:
To:
(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.

#1067196#35
Date:
2024-04-29 05:09:06 UTC
From:
To:
Jay Berkenbilt dixit:

That explains it very well and not ambiguous to nōn-native
speakers (I hope).

Thanks,
//mirabilos