Copy link to clipboard
Copied
Hello dera friends,
in the published post `Get and Set PDF metadata from Acrobat JavaScript` by Mr. Thom Parker (https://acrobatusers.com/tutorials/get-and-set-pdf-metadata-from-acrobat-javascript/) is code for changing `Custom properties` in Acrobat. The JS code is: this.info.mySpecialProp = 3; // Create a custom entry
I'm wondering how to add a DOT in the code above? Namely, if I want to use a code with a dot like `this.info.mySpecial.Prop = 3; (where DOT is present in custom name aka mySpecial.Prop)` this JS code does not work with the ActionWizard function. Can someone help me to solve the problem? Thanks in advance for your reply and any suggestion.
BR Aljoša
Copy link to clipboard
Copied
As with most JS properties, you can do it if you access the property name as a string, instead of a variable name.
So use this instead:
this.info["mySpecial.Prop"] = 3;
The result:
You'll also need to access it the same way later on, though.
Copy link to clipboard
Copied
The info object is accessed by properties that are JavaScript names. You cannot use a dot in a name. So, this seems impossible; I suggest you rethink your plans.
Copy link to clipboard
Copied
As you can see the dot is used as a separator, so you cannot use it in a custom metadata name.
Copy link to clipboard
Copied
Hi there and thanks JR Boulay and Test Screen Name...I kown that but I also needed confirmation from any of you by`those who know more' that there is no trick/hack that I could use...unfortunately, I need a DOT because of the requirements of the agencies and because we have a lot of these kinds of documents...well...I will correct the change of record with Notepad++ (its time consuming, but I will satisfy the agencys requirements according to the record in `custom properties`). I wish you a nice and pleasant day. Regards Aljosa
Copy link to clipboard
Copied
As with most JS properties, you can do it if you access the property name as a string, instead of a variable name.
So use this instead:
this.info["mySpecial.Prop"] = 3;
The result:
You'll also need to access it the same way later on, though.
Copy link to clipboard
Copied
That's a neat trick! Thank you.
Copy link to clipboard
Copied
OMG !!!...try67 you are a GENIUS...I can't believe IT WORKS..I already tried it myself but apparently wrong (I put a dot in brackets (aka [.] and ["."] but it didn't work) .Now it works like magic. If you will ever been nearby Slovenia I'll take you for a beer right away ..or a seven...THANK YOU VERY MUCH. Regards from here. Aljosa
Copy link to clipboard
Copied
You're welcome! But seven beers is a bit much for me... Let's settle on three and a hot-dog! 🙂
Copy link to clipboard
Copied
Slovenian beers are famous!
Copy link to clipboard
Copied
My dear try67 ... I mean it...you have done us a very big favor..and don't worry...I will arrange all those beers with food...and transportation for a safe trip home too...I am beyond grateful and on behalf of everyone...THANK YOU BECAUSE WE HAVE YOU. BR Aljosa
Copy link to clipboard
Copied
Is there a way to include letters with accents in the metadata name. When I try this as above, it creates the name but excludes any accented letters. Example: this.info["ÄBC"]=123 creates name BC, value 123
Copy link to clipboard
Copied
It might work if you edited the metadata XML string directly. Apply the value manually and then examine it like this via the JS Console:
this.metadata
You'll see it appears as a tag towards the end of the string:
So to add it using a script you would need to read the file's metadata property, edit it, and then re-apply it.
Copy link to clipboard
Copied
That worked. Thank you. I can't do anything manually. It's all automation. I'm going to have to replace each possible accent letter with another value, then rewrite the metadata, replacing those values back:
this.metadata=this.metadata.replace(/-A-/g,"Ä")
There's (*almost*) always a way. Thanks again.
Copy link to clipboard
Copied
This isn't exactly what I meant, but that works too, I guess!
And the manual part was just to see how it needs to appear in the metadata XML string. You do it manually so you know how to automate it later on.
Copy link to clipboard
Copied
What you suggested did not work for me, but this did:
this.info["xxxAxxxBC"] = "123";
this.metadata=this.metadata.replace(/xxxAxxx/g,"\u00C4")
Copy link to clipboard
Copied
Correct. I used "\xC4" instead of "\u00C4". Is there a script that you know of that converts characters to the ASCII or unicode values? Thanks again.
Copy link to clipboard
Copied
The best way is to Google it: "Ä unicode"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now