Skip to main content
New Participant
March 18, 2021
Answered

Javascript in action wizard for copyright notice and status needed

  • March 18, 2021
  • 3 replies
  • 2438 views

Hi,

I have to batch process a number of files in Adobe DC. I'm using the action wizard and have the javascript for the title and author, but I also need the javascript for additional metadata to change 'copyright status to copyrighted' and 'copyright notice to the name of my company'. Does anyone have or know the script for that? I'm not a js expert.

Thanks

 

Paul

This topic has been closed for replies.
Correct answer Mike Bro

Hello Paul,

 Add the code below to your Acrobat Action to set the 'copyright status to copyrighted' and 'copyright notice',  you'll need to plug in the Company info and web address if any, if no web address is to be added just clear the info leaving the ""

I  recommend adding a second javascript tool to your action for this.

 

 

var CopyrightStatus = "True";
var CopyrightNotice = "Copyright(C) 2021, Your Company Name goes here."
var CopyrightInfoURL = "http://www.yourcomanyweb.com"
var meta = this.metadata;
var myXMPData = new XML(meta);
myx = new Namespace("adobe:ns:meta/");
myrdf = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
mypdf = new Namespace("http://ns.adobe.com/pdf/1.3/");
myxap = new Namespace("http://ns.adobe.com/xap/1.0/");
mydc = new Namespace("http://purl.org/dc/elements/1.1/");
myxapRights = new Namespace("http://ns.adobe.com/xap/1.0/rights/");
var p = myXMPData.myrdf::RDF.myrdf::Description;

if (p.mydc::rights.myrdf::Alt.myrdf::li.toString() == "") {
p[0] += <rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<dc:rights>
<rdf:Alt>
<rdf:li xml:lang="x-default">
{CopyrightNotice}
</rdf:li>
</rdf:Alt>
</dc:rights>
</rdf:Description>
} else
p.mydc::rights.myrdf::Alt.myrdf::li = CopyrightNotice;

if (p.@myxapRights::Marked.toString() == "" ) {
p[0] += <rdf:Description rdf:about=""
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/">
<xapRights:Marked>{CopyrightStatus}</xapRights:Marked>
<xapRights:WebStatement> {CopyrightInfoURL} </xapRights:WebStatement>
</rdf:Description>
} else {
p.@myxapRights::Marked = CopyrightStatus;
p.@myxapRights::WebStatement = CopyrightInfoURL;
}
myNewXMPStr=myXMPData.toXMLString();
this.metadata = myNewXMPStr;

 

 

Regards,

Mike

3 replies

Mike BroCorrect answer
Brainiac
March 18, 2021

Hello Paul,

 Add the code below to your Acrobat Action to set the 'copyright status to copyrighted' and 'copyright notice',  you'll need to plug in the Company info and web address if any, if no web address is to be added just clear the info leaving the ""

I  recommend adding a second javascript tool to your action for this.

 

 

var CopyrightStatus = "True";
var CopyrightNotice = "Copyright(C) 2021, Your Company Name goes here."
var CopyrightInfoURL = "http://www.yourcomanyweb.com"
var meta = this.metadata;
var myXMPData = new XML(meta);
myx = new Namespace("adobe:ns:meta/");
myrdf = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
mypdf = new Namespace("http://ns.adobe.com/pdf/1.3/");
myxap = new Namespace("http://ns.adobe.com/xap/1.0/");
mydc = new Namespace("http://purl.org/dc/elements/1.1/");
myxapRights = new Namespace("http://ns.adobe.com/xap/1.0/rights/");
var p = myXMPData.myrdf::RDF.myrdf::Description;

if (p.mydc::rights.myrdf::Alt.myrdf::li.toString() == "") {
p[0] += <rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<dc:rights>
<rdf:Alt>
<rdf:li xml:lang="x-default">
{CopyrightNotice}
</rdf:li>
</rdf:Alt>
</dc:rights>
</rdf:Description>
} else
p.mydc::rights.myrdf::Alt.myrdf::li = CopyrightNotice;

if (p.@myxapRights::Marked.toString() == "" ) {
p[0] += <rdf:Description rdf:about=""
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/">
<xapRights:Marked>{CopyrightStatus}</xapRights:Marked>
<xapRights:WebStatement> {CopyrightInfoURL} </xapRights:WebStatement>
</rdf:Description>
} else {
p.@myxapRights::Marked = CopyrightStatus;
p.@myxapRights::WebStatement = CopyrightInfoURL;
}
myNewXMPStr=myXMPData.toXMLString();
this.metadata = myNewXMPStr;

 

 

Regards,

Mike

New Participant
March 19, 2021

Thanks very much Mike, That code worked like a charm. 🙂 

JR Boulay
Adobe Expert
March 18, 2021

It should be easier to use custom metadata:

 

this.info.Copyright_status = "copyrighted";
this.info.Copyright = "the name of my company";

 

 

Acrobate du PDF, InDesigner et Photoshopographe
Brainiac
March 18, 2021

You can certainly create custom metadata easily and call it anything you like, including "Copyright" or "My company's IP rights". These will show up on a manual inspection of the custom metadata.

 

However, that might not solve the original need. There is a standard place to keep copyright status, copyright statement, and copyright URL. This is not done with custom keywords, but is stored in the XMP metadata. This is then consistent with other formats like TIFF and JPEG when they store copyright, and utilities might report this. In Acrobat, this is shown in Document Properties -- Additional metadata -- Description. The structure of copyright info in the XMP data is complex. Info dictionary, and the info object are essentially obsolete, especially in PDF 2.0 where the Info dictionary is forbidden.

New Participant
March 19, 2021

Thanks for your reply and information.

Brainiac
March 18, 2021

It's not simple, but see the document.metadata object in the JavaScript API. There seems to be an example of a very similar requirement. It would be best to start with some knowledge of XDP and XML.

Brainiac
March 18, 2021

Sorry this reply was for Paul...

New Participant
March 19, 2021

Thanks for your reply, I managed to get the right code in this thread.