Skip to main content
namithap5724996
Participating Frequently
June 2, 2016
Question

We are trying to bring out the version control to the forms using the latest checked in tfs Date and we found that this date is captured in the Metadata (XMP File) of the form. We are able to view the Metadata from Adobe Reader by placing the atta

  • June 2, 2016
  • 8 replies
  • 3257 views

We are trying to bring out the version control to the forms using the latest checked in tfs Date and we found that this date is captured in the Metadata (XMP File) of the form.

We are able to view the Metadata from Adobe Reader by placing the attached '.js' file ShowXMPData.js in the path "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\Javascripts" . Attached screenshot for your reference.

Now the available MetadataDate need to access in the form to implement the version control. I found the below code to extract the Metadata with Adobe XMP, but we are unable to load the Adobe XMP Script Library. Not executing the below initial code:   

                if ( !ExternalObject.AdobeXMPScript ){

Do we need any external setup to read the contents of XMP file inside the PDF. Could you please suggest on this to access the Metadata in Adobe.

Can anyone tell more details on what is ExternalObject please

This topic has been closed for replies.

8 replies

Legend
June 8, 2016

Oh I see it is an XFA form. In that case I'm sorry it is outside my knowledge.

Legend
June 8, 2016

Do not use "this" in the console. I have said, use it only in events.

Legend
June 8, 2016

I see your calling code is referring to "this". So in what event do you use that calling code? Context is important. Also, does the message really say "oDOC" or does it say "oDoc"? Did you copy/paste this code, or retype it for the post?

namithap5724996
Participating Frequently
June 8, 2016

I have used 'oDoc'. Below is the error pop up during debugging

namithap5724996
Participating Frequently
June 8, 2016

I am calling this code in 'Initialize' event in adobe designer

Legend
June 7, 2016

Don't use "this". Just forget it exists except in event handlers. Find another way to reference the document for which you want to receive this information.

namithap5724996
Participating Frequently
June 8, 2016

Hi,

I tried the below code 'oDoc.info.ModDate;' as mentioned, but it is showing as "'oDOC' is not defined" Kindly help.

// define a folder level script to obtain the ModDate for the PDF;
function getModDate(oDoc)
{
// get the modification date for the doc indentified with the parameter oDoc;
return oDoc.info.ModDate;
} // end getModDate function;


// code to execute in the open document;
app.alert("This document was last modified on " + util.printd("mmm dd, yyyy", getModDate(this)), 3, 0);

Legend
June 7, 2016

(1) Your problem may be the use of the object "this". The meaning of "this" depends on the context (see the JavaScriptAPI Reference). Use it in events. Never use it in startup scripts. Recode to avoid.  I have no comment on whether the code is otherwise correct, since we cannot know what you even intended "this" to be. When showing a startup script please also show calling code and tell us which event is used.

(2) It looks as if XMLData is documented, though following it in full needs to follow the references to other documents - please clartify where the documentation needs clarification. You will certainly need to know the XMP schema.

Inspiring
June 2, 2016

You can create a folder level script to extract the ModDate from the document. You will have to pass the document object to the function.

namithap5724996
Participating Frequently
June 7, 2016
Hi,
I tried populating the last modified date into my form using the folder level javascript.
Hence I have placed the below '.js' file to the path "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\Javascripts\script.js"

and called the function "this.rawValue =  getModDate();" into my form. But no date is displayed into my form. Can anyone please suggest where I am doing wrong.

Below code in script.js file:


var getModDate = app.trustedFunction(function () { 
        app.beginPriv();
        var ModifiedDate = this.info.ModDate;
        return ModifiedDate;
        app.EndPriv(); 
    } 
);


Code called In Form:


this.rawValue =  getModDate();

Bernd Alheit
Community Expert
Community Expert
June 7, 2016

What happens when you call getModDate(); in the debugger?

Legend
June 2, 2016

I do not recognise ExternalObject as part of Acrobat JavaScript. indeed, you cannot  run external apps or dolls from Acrobat JavaScript by any method.

As I mentioned, you cannot port JavaScript meant for other apps.

namithap5724996
Participating Frequently
June 2, 2016

Is there any other way to fetch the tfs last modified date alone in the pdf? Please help.

Bernd Alheit
Community Expert
Community Expert
June 2, 2016
Legend
June 2, 2016

please come back and attach screen shot using camera icon. No direct attachments are possible. Please link to or copy .js file. Be sure by the way that your JavaScript was for Acrobat. You cannot port in from other apps.

namithap5724996
Participating Frequently
June 2, 2016

Hi,

I have attached the screen shot and also Below is the js code which we place in the below path.

C:\Program Files (x86)\Adobe\Reader 11.0\Reader\Javascripts" .

app.addMenuItem({ cName: "ShowXMPData", cUser: "Show XMP Data", cParent: "Edit", 
    cExec: "console.show(); console.clear(); console.println(this.metadata);", cEnable: "event.rc = (event.target!=null);"});

Please help.

try67
Community Expert
Community Expert
June 2, 2016

I don't understand what's the issue. Your code works fine. It opens the console window and displays the file's XMP metadata.

What else do you want it to do?