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

Stamps

New Here ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

Hello,

I read a lot on internet.
Who can help me or put me in the right direction.

I use Adobe Acrobat DC pro.
I've created a stamp. When a user put this stamp on a document the 'stamp' ask for some questions :

The user has to fill in the question. One question is the filename.
So I want that when the user has filled in the questions that document with stamp will be saved in a folder and filename the user has filled in.
I read a lot about mySaveAs and Adobe LiveCycle and buttons and Folder Level Scripts but it don't work.

How can I give the information filled in by the user in the stamp to the Folder Level Script so the document will be saved with the filename the user has filled in ?

And also for the folder. The folder : "/c/ " and then the company name the user has filled in.

Thanks and regards.

TOPICS
Acrobat SDK and JavaScript

Views

4.2K

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 ,
May 30, 2017 May 30, 2017

Copy link to clipboard

Copied

Yes, this is the correct methodology, except you should name the info property for the data.

event.source.source.info.Supplier = Supplier;

event.source.source.info.InvoiceNum= InvoiceNum;

event.source.source.info.Company = Company;

These make a lot more sense than "DocumentState". 

Also, instead of the "app.response" box, I'd use a custom dialog. Dialogs however are much more difficult to create than the code we've just worked though.

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
New Here ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Hello,

Is there also the possibility to check if the user filled in the correct information ?

Example : the stamp ask for a period (YYYYMM) so a check if the data is 201706 and not AZDIKS of 201405 (2014 is before 2017)

Thanks

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

If you're using a Dialog object you can do it in its validate event to prevent the user from proceeding (unless they click Cancel or close the dialog). Otherwise you can validate the input but if it's incorrect you can't prevent the stamp from being placed. You can only show an error message and force the fields in the stamp to be empty.

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 ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

I've put the code below in the Validate tab :

event.rc = true;

if (event.value.length == 6 && event.value > 201700 && event.value < 203000) { event.target.textColor = color.orange; } else { app.alert("The entered value needs to be 6 characters long and format YYYYMM !"); event.target.textColor = color.red; }

When the user enter a wrong value the value in the stamp is Red.

That's OK.

example : enter 201407 and you this value in Red. That's OK.

But when you close the document (not Adobe) and you open the document again, because I've enter a wrong value in the stamp, then enter a good value example 201707 then this value is also in Red.
So, how can I reset the values for all the fields in a stamp ?
Is that possible ?

Thx

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 ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

- There's no such thing as "color.orange". Use this instead:

event.target.textColor = ["RGB", 1, 0.5, 0];

- Run this code to reset all the fields in the file:

this.resetForm();

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 ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

Where do I put the 'this.resetForm()' command ?

I put this command in the first stamp field and this works when I open a PDF and put the stamp.

But when I put the stamp and enter a wrong value. Then close only the document (but PDF is still open) and put the stamp again on the document the value is in red. Meaning that de value of the fields are still remaining and aren't reset.

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 ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

This command needs to be at the top of the code. It will get executed before you apply the stamp, not afterwards. So it's possible that the old text will appear in the stamp's icon, if that's what you mean. That can't be avoided.

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 ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

you can work with 'event.target.textcolor'= color.black

The text.color orange (color.orange) doesn't exist. I configured it in the 'appearance' tab.

Therefore i saw 'orange' text.

When I changed the command to event.target.textcolor = color.yellow it's works.

Thx for your quick respons.

You can also see the link for the RGB code

http://www.windjack.com/resources/Examples/ColorCalculator.pdf

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

on TERMINAL SERVER :

In which folder do I have to put the MenuItem.js and mySaveproc.js files (javascripts) ?

In which folder the dynamic stamp ?

On my test computer, with Acrobat DC, the stamp and script works.

Then I want to put the files on terminal server but it don't work.

Javascript folder : C:\Program Files (x86)\Adobe\Reader 11.0\Reader\Javascripts

Stamp :  C:\Users\USER\AppData\Roaming\Adobe\Acrobat\11.0\Stamps

I use the code you see above.

In the stemp I ask for company. I choose a company and on my test computer I can save the file tine right folder.

When I copy the files on terminal server then it don't work.
When I use an app.alert for company the value is null. I see a screen with red cross.fsqqf

What do I wrong ?

Thx

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

You're not allowed to use Acrobat as a service on a server.

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

Does that mean that I can't work with a dynamic stamp and Folder Level Scripts, I created on a local computer, on a terminal server ?

Are there work-arounds ?

Thanks for the quick respons.

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

I'm not a lawyer, but I think as long as you're only using the application locally then it's OK.

This has nothing to do with the stamps, by the way. It's a legal (and technical) limitation.

The stamps should work fine, as long as you install them in the correct folder. You said you have Acrobat but the path you gave of the JavaScripts folder is of Reader... So something is not right there.

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

On my test computer I've Acrobat DC pro to create the Dynamic Stamp.

Stamp ask for questions like 'For which company'.

And that works fine in the test computer.

Now I want to install the stamp and scripts so the whole company can use the stamp.

So therefore the path you see is the Reader path.

On my test computer I've the Reader en DC Pro installed.

So what the correct folder for the javascripts and stamps are I don't know for sure.
I test some folders but without results.

So I hope that somebody can help me.

Thx

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

The stamps folder is the same, I believe:

C:\Users\<USERNAME>\AppData\Roaming\Adobe\Acrobat\<VERSION>\Stamps

The JavaScripts folder for Acrobat is:

C:\Program Files (x86)\Adobe\Acrobat <VERSION>\Acrobat\Javascripts

And for Reader it's:

C:\Program Files (x86)\Adobe\Reader <VERSION>\Reader\Javascripts

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

These folders are correct (I think because I placed the files in these folders.

The event.source.source.info.Documentstate doesn't work now.
On the local test computer with Acrobat Adobe Pro As test I do a app.alert(company);

On the test computer I see the company I choose.

But on the terminal server I see a screen with a red cross and without any information.
Therefore I think something is wrong but I don't now what.

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

Reader can't change the file's metadata, which is why this line of code fails.

Do you really need it? If so, then you need to add an if-condition that checks if the stamp is being used in Acrobat first.

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

Yes, I really need the file's metadata.

Because I save the file in the "company" folder the user choose in the stamp.

Do you know the "IF-condition" command ?
Thx

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

Well, you can't do it in Reader.

Try this code:

if (app.viewerType!="Reader")

     event.source.source.info.DocumentState = cMsg;

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 ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

Well you know, as Try67 says, the issue is with the storage location.  But the important bit here is not the specific location, but the data. So, you can simply use a different location. For example, any global generic object. It's important that the object is both global and generic, so that it can be seen everywhere and handled generically. For example the "color" object. Just replace "event.source.source.info" with "color" and see how that works.

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
New Here ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

I don't know what you mean with "color object' and replace 'event.source.source.info'.

I need the event.source.souce.info command to put the value of a field to the document metadata.  So I can get the value in my Folder Level Script.

I use only colors in the validate tab. So I think their is  a miscommunication.

In detail my problem :

I've a standalone computer with Adobe DC Pro.

I've created a dynamic stamp and a Folder Level script.

On my local computer (Windows 7) I get the value from a field in the stamp to my script. This mean I can save the document in example company folder the user choose in the stamp.

That's OK. So everything works on my local computer.

I copied the files on a Terminal Server with Windows 2012 server R2 Operating System in the folder like Try67 described.

Now it's not possible to get the value from a field in the stamp to the script.

When I do an app.alert for company in the script it gives a pop-up with only a red cross. Not the value I chose from the stamp.

If I do that on my local computer I see the value I chose from the stamp.

On the Terminal Server we use Adobe Acrobat Reader version 11.0.20

I've administrator rights.

I think the code is correct because it works on the local machine.
But why isn't working on the Terminal Server ????

Is there a difference between metadata on a local machine and a terminal server ?

Do you need another command to write the value from a stamp to the 'terminal server' metadata ?

1) MenuItem.js

app.addMenuItem({

       cName: "Company Save and E-mail Stamp",

       cParent: "File",

       cExec: "mySaveProc();",

       cEnable: "event.rc = (event.target != null);",            

       nPos: 7   

});

2) Dynamic Stamp

The code behind field "Company" :

var oList = {A:-1, B:-1, C:-1, D-1, E:-1, F:-1};

var cTitle = "Company";

var dlg = {

    initialize: function(dialog)

                { dialog.load({lst1:oList});},

    commit: function(dialog)

                 {this.oSelect = dialog.store().lst1;},

    description:

    {

       name:"Company name",

       elements:[{type:"view", elements:[

               {type:"static_text", item_id:"stat",

                   name:"Select company"},

               {type:"popup", item_id:"lst1", char_width:15},

               {type:"ok"}]}]

     }

};

if(event.source.forReal &&

       (event.source.stampName == "#Stamp"))

{

     if("ok" == app.execDialog(dlg))

     {

        var cRtn = "Off";

        for (cRtn in dlg.oSelect)

            if(dlg.oSelect[cRtn] > 0) break;

       

        var Company = this.getField("Company").value = cRtn;

        event.value = Company;

        if (app.viewerType!="Reader") //Try67 give me this information

           event.source.source.info.company = Company;

     }

}

3) mySaveProc.js

var mySaveProc= app.trustedFunction(function()

app.beginPriv();  

var myDoc = event.target;

app.alert(myDoc.info.company); // show the value I chose from the company field in the dynamic stamp

var folder = myDoc.info.company;

The rest of the code

app.endPriv(); 

return myDoc; 

});

How  can I resolve this problem ?

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 ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

I already explained why it's not working. The difference is between using

Acrobat and Reader. Only Acrobat can edit a file's metadata.

There's no way around that.

On Thu, Jun 8, 2017 at 1:38 PM, testt70366819 <forums_noreply@adobe.com>

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 ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

Sorry Try67, for my mistake.

Yesterday you wrote :

Reader can't change the file's metadata, which is why this line of code fails.

Do you really need it? If so, then you need to add an if-condition that checks if the stamp is being used in Acrobat first.

My reply was : yes, i need this information and I put the if-condition in the code :

if (app.viewerType!="Reader")

           event.source.source.info.company = Company;

So, will this means that this command isn't the solution and in Reader I can't work with the metadata ?

And their is no alternative to get the value from a stamp field to the script ?


Thx

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 ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

The solution I provided is so that the rest of your code works, by ignoring

this line when the stamp is used in Reader.

As Thom said, if the reason you're doing it is just to pass a value from

one place to another there are better options, like a global variable.

Using the file's metadata for that is really not a good approach.

On Thu, Jun 8, 2017 at 1:51 PM, testt70366819 <forums_noreply@adobe.com>

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 ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

OK, thanks for your info.

Than I had misunderstood your email yesterday.

Without your if-condition I had errors. With your command not.
So I thought now, with you help, it will work.

So I can't use metadata but it can work if I use global variable.

Now, i'm not a specials but can you help me how to do that in my company example ?

Or do I have to change a lot in the code ?

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 ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

I found the solution :

In the stamp :

global.company = this.getfield("Company").value = cRtn,

In the script

app.alert(global.company);

Thx

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