JavaScript help - making all object ID for xobjects unique

New Here ,
Feb 20, 2020

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!

 

 

Most Valuable Participant
Correct answer by Test Screen Name | Most Valuable Participant

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?

TOPICS
Acrobat SDK and JavaScript

Views

150

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

JavaScript help - making all object ID for xobjects unique

New Here ,
Feb 20, 2020

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!

 

 

Most Valuable Participant
Correct answer by Test Screen Name | Most Valuable Participant

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?

TOPICS
Acrobat SDK and JavaScript

Views

151

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 20, 2020 0
Most Valuable Participant ,
Feb 20, 2020

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 20, 2020 0
New Here ,
Feb 20, 2020

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 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 20, 2020 0
Most Valuable Participant ,
Feb 21, 2020

Copy link to clipboard

Copied

An interesting discussion. Thanks for the link, I added to it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0
Adobe Community Professional ,
Feb 20, 2020

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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 20, 2020 0
Most Valuable Participant ,
Feb 21, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0
Adobe Community Professional ,
Feb 21, 2020

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 😉

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0