Copy link to clipboard
Copied
Hi
I'm trying to write the javascript for a custom command that runs through a document and finds all xobjects with duplicate object ID and changes the object IDs so they are unique. For context, the xobjects with duplicate object ID's is about 1-2% or less of all xobjects.
I've been struggling to find which part of the api relates to what I want to do, if someone is able to point me in the right direction or have an example?
Any help is much appreciated!
JavaScript can't do anything like that, nor get near it. There is no access to page objects. Plug-ins, in C++, have low level access. Why would you want to do this? Shared XObjects is a design aim of PDF, so that identical content does not have to be duplicated. You cannot change an object ID at all, but you could duplicate objects and hence get new object IDs. But why just make the file bigger?
Copy link to clipboard
Copied
JavaScript can't do anything like that, nor get near it. There is no access to page objects. Plug-ins, in C++, have low level access. Why would you want to do this? Shared XObjects is a design aim of PDF, so that identical content does not have to be duplicated. You cannot change an object ID at all, but you could duplicate objects and hence get new object IDs. But why just make the file bigger?
Copy link to clipboard
Copied
Thanks! That explains why I couldn't find anything, it's not really possible/practical.
I was looking at this in relation to After applying redactions other information is removed
Copy link to clipboard
Copied
An interesting discussion. Thanks for the link, I added to it.
Copy link to clipboard
Copied
You do know that indirect object IDs in a PDF have to be properly referenced in the object lists and cross reference table? Even with a plug-in you can't simply change an ID. This is a fundamental part of the PDF structure. You would have to access the PDF at the byte level to make this kind of change.
Oddly enough you can actually do this with Acrobat JavaScript. There's an undocument document object function that provides a byte stream of the PDF file contents.
Copy link to clipboard
Copied
That's an interesting hidden feature. Editing PDF objects (and duplicating form XObjects and updating references), via JavaScript on a bytestream... I think it's fair to say that wouldn't be for the faint-hearted.
Copy link to clipboard
Copied
Ha, ha, yes, building a PDF parser within Acrobat JavaScript would be quite the challenge. The biggest problem wouldn't be the XRef table, it would be decompressing the object collections. I'll leave that to someone with more time 😉