qpdf icon indicating copy to clipboard operation
qpdf copied to clipboard

Keep the Original object ID and order

Open edgaru opened this issue 6 years ago • 6 comments

Is it possible to keep the same object id and its order as the original file?

When I generate the modified file, the order of the objects is different as well as its id.

Thanks,

edgaru avatar Jul 01 '19 02:07 edgaru

This also seems like it could be similar to #338. I can consider this request, but I won't commit to it. Preserving object ID may be something I could consider, though qpdf may not always write out exactly the same objects, particularly when it comes to stream lengths. I don't think it's likely that I will try to preserve the order. qpdf doesn't directly have any concept of order, except in the case of linearized files where the order is dictated by the spec. There is enough information to compute the order, but it would be a lot of extra work with no special benefit.

Can you share your use case for wanting the ID and order to be preserved? Thanks.

jberkenbilt avatar Jul 02 '19 14:07 jberkenbilt

I have other work that may require this, particularly supporting incremental updates. It's not going to happen soon, but it's something I'm thinking about. I think it may happen.

jberkenbilt avatar Dec 29 '23 16:12 jberkenbilt

(sorry, closed by mistake). Also, I think it's more likely that I would preserve object ID than order.

jberkenbilt avatar Dec 29 '23 16:12 jberkenbilt

Just wondering is there any progress on this issue? Any PR or branch I can look at? Just wondering, because I'm trying to evaluate an encryption issue, which uses the object ID as part of its key (pre-PDF 2.0) and I'd like to be able to decrypt and then re-encrypt a file with the same object ID's so that the encryption (theoretically) stays the same.

gaekwad avatar May 16 '24 15:05 gaekwad

Sorry, no progress on this issue.

jberkenbilt avatar May 17 '24 11:05 jberkenbilt

One use case for this modifying LibreOffice's "Hybrid PDFs." They're just PDFs with the original ODT attached, but it seems to rely on the attachment having ID 1. As far as I can tell, there's not currently such a way to compress such a file with qpdf without it getting rejected, as the ID will change when using the "generate object streams" option and there's no way to change it back.

ReveredOxygen avatar Feb 19 '25 00:02 ReveredOxygen