Can't delete custom document info

Explorer ,
Jan 16, 2018

Copy link to clipboard

Copied

If I open a PDF that has no custom meta data under document.info, I can add a new meta data entry by running the following code in the console:

this.info.foo = "bar";

If I then save the document the "foo" meta data entry persists. However, if I try to delete the meta data entry by running the following code in the console:

this.info.foo = null;

Right after running this code to delete the meta data entry, if I look in Document properties the entry no longer shows. However, as soon as I hit Save the "foo" meta data entry shows up again. It seems there's no way to persist the removal of metadata entries.

Is there something I'm doing wrong?

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

The correct way to remove a property is to delete it

delete this.info.foo;

Unfortunately that doesn't work either.

The info data is tricky.  Back way when, it really was the document metadata. But that hasn't been true for a while. Now it's just a convenience. The real metadata is stored as XML in the "doc.metadata" property.  If you delete an "info" property, or set it to null, it only changes the "info". It doesn't change the XML metadata. You can  see and edit the XML from the "Additional Metadata" button on the "Description" tab of the document properties dialog.  Editing the metadata really does change things.

I'm sure this is a bug. The "info" property is supposed to edit the XML, and it does when setting a property. It should work the same for deleting a property.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

323

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

Can't delete custom document info

Explorer ,
Jan 16, 2018

Copy link to clipboard

Copied

If I open a PDF that has no custom meta data under document.info, I can add a new meta data entry by running the following code in the console:

this.info.foo = "bar";

If I then save the document the "foo" meta data entry persists. However, if I try to delete the meta data entry by running the following code in the console:

this.info.foo = null;

Right after running this code to delete the meta data entry, if I look in Document properties the entry no longer shows. However, as soon as I hit Save the "foo" meta data entry shows up again. It seems there's no way to persist the removal of metadata entries.

Is there something I'm doing wrong?

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

The correct way to remove a property is to delete it

delete this.info.foo;

Unfortunately that doesn't work either.

The info data is tricky.  Back way when, it really was the document metadata. But that hasn't been true for a while. Now it's just a convenience. The real metadata is stored as XML in the "doc.metadata" property.  If you delete an "info" property, or set it to null, it only changes the "info". It doesn't change the XML metadata. You can  see and edit the XML from the "Additional Metadata" button on the "Description" tab of the document properties dialog.  Editing the metadata really does change things.

I'm sure this is a bug. The "info" property is supposed to edit the XML, and it does when setting a property. It should work the same for deleting a property.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

324

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
Jan 16, 2018 0
Adobe Community Professional ,
Jan 16, 2018

Copy link to clipboard

Copied

The correct way to remove a property is to delete it

delete this.info.foo;

Unfortunately that doesn't work either.

The info data is tricky.  Back way when, it really was the document metadata. But that hasn't been true for a while. Now it's just a convenience. The real metadata is stored as XML in the "doc.metadata" property.  If you delete an "info" property, or set it to null, it only changes the "info". It doesn't change the XML metadata. You can  see and edit the XML from the "Additional Metadata" button on the "Description" tab of the document properties dialog.  Editing the metadata really does change things.

I'm sure this is a bug. The "info" property is supposed to edit the XML, and it does when setting a property. It should work the same for deleting a property.

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...
Jan 16, 2018 1
Explorer ,
Jan 16, 2018

Copy link to clipboard

Copied

Thanks for the response. I initially tried doing:

delete this.info.foo;

but that didn't even remove the property before saving whereas setting it to null at least removing it and made it persist until saved. Ok yes, it sure sounds like a bug. Since you said the "info" property is more of a convenience, is there a way for me to set meta data in JavaScript another way?

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...
Jan 16, 2018 0
Adobe Community Professional ,
Jan 16, 2018

Copy link to clipboard

Copied

Yes, the meta data is just an XML string and it can be set. But it's tricky, it has to be done in the right way or Acrobat will choke and ignore the change.

There is an example, and an explanation of how to do it correctly in the doc.metadata entry in the Acrobat JavaScript Reference, here:

Acrobat DC SDK Documentation

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...
Jan 16, 2018 2