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.
Copy link to clipboard
Copied
I've another question :
see the company code :
I've a dropdown.
When I push OK button (without to make a choose) then I see a value on the stamp.
This is maybe a bad example but I have a dropdown field and then it's possible to have a 'blank' line.
So, for a dropdown menu and the user push on OK without making any choice then a blank line and not the last value or default value.
Thx
Copy link to clipboard
Copied
And my second question to be certain :
If the user click on the OK button but the field is empty or didn't choose something that they get a warning.
An error message.
So two questions :
1) Dropdown and didn't chose an option than the event.value = "" (display no value on the stamp for that field)
Exception : for other dropdown fields an error message. (or event.value = "WRONG INPUT" in red).
Because these fields are critical.
Example : supplier. We save the document under the supplier folder. So the user has to chose a correct option.
2) A input field (like supplier. User has to fill in) but click on OK without a filled in field (empty field) also WRONG INPUT.
Thx
Copy link to clipboard
Copied
Hello,
I use this code to check if the user filled in characters.
var reg = /^[a-zA-Z ]*$/g;
event.rc = reg.test(event.value);
But how can I display a message when the input is wrong ?
What is the value frm event.rc if I fill in a good or bad value ?
A message like this :
if (event.rc = true) { event.target.textColor = color.black; } else { app.alert("Field [number]: The entered NUMBER value is not correct !. See if you used special characters like / , * . "); event.target.textColor = color.red; };
The problem I've is that de wrong value will not be displayed on the stamp.
When I do that with another field without this 'reg ... test' then I see the wrong text in red.
Thx
Copy link to clipboard
Copied
I'm having a hard time following you, but you have a mistake in the code above.
The comparison operator is "==", not "=". That's the value assignment operator.
So you should use this:
if (event.rc == true) ...
Instead of:
if (event.rc = true) ...
Copy link to clipboard
Copied
Hi Try67,
Sorry for the misunderstandings or annoying questions.
But when I use the code below and I fill an ABC in the field then I get an error message and I see ABC in red in the stamp.
With the other code and I give a wrong value the I don't see the wrong value in red.
When I fill in a good value then I can see that.
The problem with = and == was a typo.
Now I see the error message but not the wrong value in red.
With this code a see the wrong value in red : (= in validation tab)
event.rc = true;
var reg = /^[0-9]*$/g;
event.rc = reg.test(event.value);
event.rc = true;
if (event.value >= 1) { event.target.textColor = ["RGB", 1, 0.667, 0]; } else { app.alert("Field [Number: The entered value must be numeric!"); event.target.textColor = color.red; }
Copy link to clipboard
Copied
Change the text color before app.alert("...")
Copy link to clipboard
Copied
Thx for your quick respons.
It's works.
Now I've, I hope, my last questions.
When the user fill in a company with 'strange' characters then they get an error message "you user strange characters like * / ?
Because I want to save the pdf to the company folder.
But when the user avoid the message and want to save the document anyway the I open the myProcsave script.
Here I test again if the company has a good value (and 5 other fields)
But how can I use a 'go to' in java ?
I test in the beginning the field values. If there is one field not correct I want to go to the end of the script.
Because in the midden I print and mail the document (and other things)
So if the values are not correct I've to skip the 'middle' of the script.
Thx
Copy link to clipboard
Copied
I open the PDF document.
I put the stamp on the document and fill in some information.
Than I do File and selfmade menu item 'File - Print - Mail'.
When the user filled in a wrong value in the stamp I want to close the PDF.
I use the command : this.closeDoc(true); but don't work.
What do I wrong ?
Thx.
Copy link to clipboard
Copied
So, the "this.closeDoc(true) statement is in the stamp script or the menu script? Is there are an error reported in the console window? The console is the first place to look whenever there is a JavaScript issue.
closeDoc(true) changes the state of the document. This can be dangerous when the document is being operated on by the script. In the stamp script "this" refers to the stamp itself, so I doubt Acrobat would allow it to be run, and it if did it might crash Acrobat cause you're closing the stamp file in the middle of applying the stamp.
If it is run from the menu script, then "this" may or may not refer to the document being stamped. It is better to reference the document directly with "event.target". But even if "this" does point to the document being stamped, there may be other things happening with the PDF that would cause "closeDoc" to not work.
So what's in the console window?
Copy link to clipboard
Copied
I've also a command 'this.print().
When I run the script on a local computer with Adobe Acrobat DC then I've no problem.
The stamp and script works OK.
When I run the script on a terminal server I got the message "this.print is not a function".
So what it's the problem with this command.
Copy link to clipboard
Copied
there is no error in the this.closedoc() command.
The script run without any error in the console
Copy link to clipboard
Copied
When I put a stamp on the document the stamp ask for some questions the user has to fill in.
But when the user fill in a wrong answer the stamp shows a message.
But then I want to close the document because now the user has to answer the other questions and then close the document.
Example : when the user enter 'strange' characters' in the filename I can save the file so the user has to start again.
With the this.closeDoc(true); in the stamp in the Custom Calculate Script it don't work.
So can i close the document and if Yes how can I do that ?
Thanks.
Copy link to clipboard
Copied
Your questions were already answered by Thom. It's not a good idea. It could cause the application to crash if you do that.
Copy link to clipboard
Copied
Hello,
I've an issue in my PDF stamp.
In the dymanic stamp I've a field "Documentnumber" with this code :
var cAsk = "Document number";
var cTitle = "Document number";
if( event.source.forReal &&
(event.source.stampName == "#Stamp")){
var Documentnumber = app.response(cAsk, cTitle);
event.value = Documentnumber;
if (app.viewerType!="Reader")
event.source.source.info.documentnumber = Documentnumber;
global.Documentnumber = Documentnumber;
}
Then I've created an own menu in Acrobat. When I choose this menu item "Save" then the PDF document is save in a folder with a name. The name is the documentnumber. I do that with global.documentnumber.
So this works fine.
Now I've created a new PDF dynamic stamp and I want the date + time as documentnumber.
if( event.source.forReal &&
(event.source.stampName == "#Stamp")){
event.value = util.printd("ddmmyyyyHHMMss", new Date());
if (app.viewerType!="Reader")
event.source.source.info.documentnumber = Documentnumber;
global.Documentnumber = Documentnumber;
}
But the problem now is that when I choose the menu "Save" then I get for global.documentnumber the value undefined instead of
example 08062019182436
What is missing in the code ?
How can I declare global.documentnumber with the value of util.printd("ddmmyyyyHHMMss", new Date()) ?
Thanks and regards
Copy link to clipboard
Copied
Where does you set the value of Documentnumber?
Copy link to clipboard
Copied
Is it called "Documentnumber" or "documentnumber"? Remember that JS is case-sensitive, so the two are not the same...
Copy link to clipboard
Copied
I've created a dynamic stamp.
Add field, name "Documentnumber" and in de "Calculate" tab I added the text :
if( event.source.forReal &&
(event.source.stampName == "#Stamp")){
event.value = util.printd("ddmmyyyyHHMMss", new Date());
if (app.viewerType!="Reader")
event.source.source.info.Documentnumber = Documentnumber;
global.Documentnumber = Documentnumber;
}
Then in the MenuItem.js I added the menu "Save".
When you choose "Save" then this start a script to save the PDF in a folder.
A part of the name is the value of Documentnumber. In the other stamp I use global.Documentnumber and that works.
(in combination with the other stamp)
But now with util.printd...... I'm not sure this is correct.
Copy link to clipboard
Copied
At no point are you defining what's the value of Documentnumber. The fact that you have a field with that name doesn't mean you can access its value like that. You need to do replace this line:
global.Documentnumber = Documentnumber;
With something like this:
global.Documentnumber = event.value;
Copy link to clipboard
Copied
It didn't work.
I changed the line to :
if( event.source.forReal &&
(event.source.stampName == "#Stamp")){
event.value = util.printd("ddmmyyyyHHMMss", new Date());
if (app.viewerType!="Reader")
event.source.source.info.Documentnumber = Documentnumber;
global.Documentnumber = event.value;
}
Copy link to clipboard
Copied
Saying "it didn't work" is not very helpful. What were the exact results of doing it?
Also, please post your other code, the one where you access this variable when saving the file.
Copy link to clipboard
Copied
It works.
I restarted everything and now I've a value.
So many thanks.
Copy link to clipboard
Copied
Sorry try67.
I was too quick with my response that I didn't read your remark.
I closed all the programs (Adobe) and now it works.
So, again, many thanks for your quick answer.
Copy link to clipboard
Copied
Hello,
Is there a way I can check witch stamp is active ?
I have created 3 'similar' stamps.
The user has to fill some information like 'for witch company' etc.
Then the user choose in Acrobat File - The menu I created.
Then a XXX.js script start.
I want to use 1 script for the 3 stamps.
So if stamp A is active then the Folder is different when stamp B open is.
So I want to check like 'if stamp A active then folder = A, if stamp B active then folder B, if stamp C active then C'.
Is this possible or do I have to create 3 menu items A, B or C ?
Or is it also possible to configure in the menuItem.js that if user == xxxx then menu B ?
Thx
Copy link to clipboard
Copied
You can check the stampName.
Copy link to clipboard
Copied
I added this rule but get an error message.
xxx.js script
if (event.source.forReal && (event.source.stampName == "#stamp")) {app.alert("Not done"); return;};
To be clear : It's not in the stamp that I want to check the stamp name. It's when you choose for File - then the menu item I created - the MySaveProc.js script.
In this script I want to check the stamp name.