• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript help - making all object ID for xobjects unique

New Here ,
Feb 20, 2020 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!

 

 

TOPICS
Acrobat SDK and JavaScript

Views

709

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
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 20, 2020 Feb 20, 2020

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?

Votes

Translate

Translate
LEGEND ,
Feb 20, 2020 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?

Votes

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
community guidelines
New Here ,
Feb 20, 2020 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 

Votes

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
community guidelines
LEGEND ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Expert ,
Feb 20, 2020 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. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
LEGEND ,
Feb 21, 2020 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.

Votes

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
community guidelines
Community Expert ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

LATEST

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 😉

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines