bebarth
Community Expert
bebarth
Community Expert
Activity
Mar 28, 2025
12:59 PM
Il faut renvoyé au second menu déroulant avec le nom correct !
Donc tu changes cette ligne :
var dependentListBoxFieldName = "dependentListBox";
par :
var dependentListBoxFieldName = "Liste déroulante4";
Et normalement il vaut mieux ne pas mettre de caractères accentués...
@+
... View more
Mar 28, 2025
11:51 AM
...j'aurais bien aimé jeter un oeil sur ton fichier !
@+
... View more
Mar 28, 2025
11:45 AM
bonjour, As-tu un fichier à partager ? N'y aurait-il pas un script de document que tu n'aurais pas attaché à ton fichier ?
@+
... View more
Mar 07, 2025
01:30 PM
1 Upvote
I totally agree with you, but the strange thing is that the script works! See attached file.
Do you know if event.commitKey only work in Custom format script as the example of the api reference. I did some tests and yes apparently.
Thanks
... View more
Mar 07, 2025
10:46 AM
The commitKey property event is briefly documented in api reference and give the 4 values (0, 1, 2 or 3) that can be returned in accordance with the way the field loose focus. https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#commitkey I personally always used this property in Custom format script as on the example of the api reference.
On the web, I found a file using commitKey in Validation script with a strange syntax:
if (event.commitKey=13…)
With a single “=” symbol and with 13 which seems to be the ascii character of the Carriage Return. And that work!!! I tried to change with "if (event.commitKey==2…)" and that doesn’t work anymore! Does anyone have an explanation? Is there a more detailed documentation for this property? Thanks
... View more
Mar 07, 2025
10:23 AM
Not sure to understand your request! What do you mean exactly?
@+
... View more
Mar 07, 2025
06:11 AM
1 Upvote
Hi,
Try that:
for (var p=0; p<this.numPages; p++) {
this.addWatermarkFromText({
cText: this.documentFileName.replace(/.pdf$/i,"\nPage "+(p+1)+" of "+this.numPages),
nTextAlign: app.constants.align.right,
cFont: "Arial,Bold",
nFontSize: 12,
aColor: color.black,
nStart: p,
bOnTop: true,
bOnScreen: true,
bOnPrint: true,
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.top,
nHorizValue: -.4*72,
nVertValue: -.5*72,
bPercentage: false,
nScale: 1.0,
bFixedPrint: false,
nRotation: 0,
nOpacity: 1
});
}
this.saveAs(this.path.replace(/.pdf$/i," (with Header).pdf"));
@+
... View more
Feb 21, 2025
10:19 AM
1 Upvote
Hi, You could use a global variable and an On Blur Action Script...
// Document Script
if (this.getField("CRITICAL1").isBoxChecked(0)) global.realValue=this.getField("MA").value*2;
else global.realValue=this.getField("MA").value;
// On Blur "MA" Field Script
global.realValue=event.value;
if (this.getField("CRITICAL1").isBoxChecked(0)) this.getField("MA").value=global.realValue*0.5;
// Mouse Up "CRITICAL1" Check Box Field Script
if (event.target.value!="Off") this.getField("MA").value=global.realValue*0.5;
else this.getField("MA").value=global.realValue;
@+
... View more
Jan 14, 2025
11:45 PM
Hi,
Here is the modified script to reach your request.
this.addWatermarkFromText({
cText: this.documentFileName.replace(/.pdf$/i,""), // The text to use as the watermark
nTextAlign: app.constants.align.right, // (optional) The text alignment to use for cText within the watermark
cFont: "Arial,Bold", // (optional) The font to be used for this watermark
nFontSize: 12, // (optional) The point size of the font to use for the watermark
aColor: color.black, // (optional) The color to use for the watermark
nStart: 0, // (optional) The 0-based index of the first page
nEnd: this.numPages-1, // (optional) The last page
bOnTop: true, // (optional) A Boolean value specifying the z-ordering of the watermark
bOnScreen: true, // (optional) A Boolean value to indicate whether the watermark should be displayed when viewing the document on screen
bOnPrint: true, // (optional) A Boolean value to indicate whether the watermark should be displayed when printing the document
nHorizAlign: app.constants.align.right, // Al(optional) A number indicating how the watermark should be aligned horizontally
nVertAlign: app.constants.align.top, // (optional) A number indicating how the watermark should be aligned vertically
nHorizValue: -.4*72, // (optional) A number used to shift the horizontal position of the watermark on the page
nVertValue: -.5*72, // (optional) A number used to shift the vertical position of the watermark on the page
bPercentage: false, // (optional) A Boolean value used to indicate whether nHorizValue and nVertValue represent a percentage of the page size or an explicit number of points
nScale: 1.0, // (optional) The scale to be used for the watermark
bFixedPrint: false, // (optional) A Boolean value that indicates that the watermark should be added as a FixedPrint Watermark annotation
nRotation: 0, // (optional) The number of degrees to rotate the watermark counterclockwise
nOpacity: 1 // (optional) The opacity to be used for the watermark
});
// To keep the same file name
//this.saveAs(this.path);
// To modify the file name
this.saveAs(this.path.replace(/.pdf$/i," (with Header).pdf"));
The action wizard is included into the attached file.
Please read this post to know how use it for several files in a same time. In a first step, try with just a few files instead of all your thouthands ones.
With this script, your files are renamed " (with Header)". If you wish to keep the original file name, use the line:
this.saveAs(this.path);
at the end of the script (but I suggest using a copy of your files).
Let me know.
@+
... View more
Jan 14, 2025
03:38 AM
Hi,
Do you want the file name on each page or only on the first one?
I guess dimensions you indicate are in inches...
Could you post a sketch of the position we need to place the file name because I am not sure to understand!
@+
... View more
Oct 08, 2024
05:06 AM
Hi,
For the modifier event property, the api reference indicates "The modifier key on the Microsoft Windows platform is Control and on the Mac OS platform is Option or Command.".
On my Macs, only the option keys works! Does anybody confirm this for all Mac OS?
Thanks
... View more
Oct 06, 2024
04:03 AM
1 Upvote
obviously! Works fine, thanks.
... View more
Oct 05, 2024
09:16 AM
I tryed to unselect via javaScript all items of a list field setting "currentValueIndices" to -1 but it seems that doesn't work.
The setting works fine to indicate the selected item(s) with a number or an array, but doesn't work for unselect all of them, whereas -1 is the value returned if no items are selected...
Is there an other way to do?
Thanks
... View more
Sep 23, 2024
10:57 AM
@Thom Parker
I've definitely been very lucky that it's worked out for me every time.
var theLine=theWord
is a re-declartion. While JS is loose enough to correct for this error, it presents both a memory managment and a scoping issue that could cause issues. Best to write scripts using proper form for robustness.
I don't understand. The first time I declare the variable without nay value with
var theLine="";
because I need it for the line #16, else it doesn't work;
var theLine=theLine.replace(/\s+$/,"");
then, in line #22, if the condition is true I attribute the "theWord" value to this variable.
For me, the declaration is only the first time (which could only be var theLine)... it is possible to change the value of a variable, isn't it?
You have this code inside the loop that iterates over the page words. The page isn't changing, so there is no reason to recreate the page coordinate conversion matrix.
And on a related note. The thePage variable is unnecessary, it serves no purpose.
Correct. This script comes from an other one where I had to check if the next line was on the same page or the next page.
@+
... View more
Sep 22, 2024
07:57 AM
@Thom Parker,
What exactly is the idea with your algorithm?
The script checks the vertical position of the bottom of each word. If the next word has the same position, it is the same line, if it is different it is a new line.
"theLine" is redeclared twice.
I don't think so! It's only declared on line #2.
the page coordinate conversion matrix should be created above the inner loop.
It's correct if all pages have the same size, but I've the habit of checking the size of each page because I've been fooled several times before.
It looks like your assumption is that the page words will be arranged in order that they appear on the page. This may not be correct, but will probably work in most situations.
I know that the order of words on a page is not always from top to bottom and from left to right, but as you say it works in most cases. When in very few cases for me it didn't work, I used the "Auto tag" action which solved my problem. I am not a "pdf" specialist, but with my few years of experience I understood that the word order was not what it should be when the text as been modified or some texts added. For me, each time the "Auto tag" action corrected the problem but certainly you can find a case where that doesn't work...
@+
... View more
Sep 21, 2024
01:09 PM
Hi, Sorry if I'm late! I've only catched your post today.
Try this script and let me know if it suits you.
var thePage=0;
var theLine=""
var nbLines=0;
for (var p=0; p<this.numPages; p++) {
var aRect=this.getPageBox("Crop",p);
var bottomWord=aRect[1];
for (var i=0; i<this.getPageNumWords(p); i++) {
var theWord=this.getPageNthWord(p,i,false);
var q=this.getPageNthWordQuads(p,i);
m=(new Matrix2D).fromRotated(this,p);
mInv=m.invert();
r=mInv.transform(q);
r=r.toString();
r=r.split(",");
if (thePage==p && bottomWord!=Number(r[5])) {
var theLine=theLine.replace(/\s+$/,"");
if (theLine.length) {
nbLines++;
console.println("\r***** I AM A NEW LINE *****");
console.println(theLine);
}
var theLine=theWord;
} else {
theLine+=theWord;
}
bottomWord=Number(r[5]);
var thePage=p;
}
var theLine=theLine.replace(/\s+$/,"");
if (theLine.length) {
nbLines++;
console.println("\r***** I AM A NEW LINE *****");
console.println(theLine);
}
}
console.println("\r***** THERE ARE "+nbLines+" LINES IN THIS DOCUMENT. *****");
@+
... View more
Sep 06, 2024
09:04 AM
Hi,
In validation script of your "Date1" field you write:
var oDate=util.scand("dd-mmmm-yyyy",event.value);
for (var i=2; i<=12; i++) {
oDate.setMonth(oDate.getMonth()+1);
this.getField("Date"+i).value=util.printd("dd-mmmm-yyyy",oDate);
}
@+
... View more
Jul 23, 2024
08:49 AM
If for example your "date" fields are "1.date", "2.date", ... you can write a function in document level:
function visibility(ind) {
var otherFields=["a","b","c","d","e","f","g"];
if (event.value=="") {
for (var i=0; i<otherFields.length; i++) this.getField(ind+otherFields[i]).display=display.hidden;
} else {
for (var i=0; i<otherFields.length; i++) this.getField(ind+otherFields[i]).display=display.visible;
}
}
then call it in validation script of each date field:
visibility(event.target.name.substr(0,event.target.name.indexOf(".")+1));
@+
... View more
Jul 23, 2024
05:40 AM
What are the names of date fields (e.g: "1.date" for line 1)???
@+
... View more
Jul 16, 2024
12:21 PM
Hi,
Here is what I did at the moment. The final layout is still missing but before do it, could you check this script on a few file.
You must choose 2 files from the open files:
Then after clicking OK you will get the result in the console window.
The script is a bit more complicated as I thougth because of what I try to explain in my previous answer...
Here is the script you can run from the console window or an action wizard:
lesDocs=[];
openDocs=app.activeDocs;
for (var d=0; d<openDocs.length; d++) lesDocs.push(openDocs[d].documentFileName);
if (lesDocs.length<2) {
app.alert("You need to open 2 files to be able to compare them.",3);
} else {
var laListe="- Select -";
var listeDocuments="var listeDocuments \= \{\""+laListe+"\": "+(lesDocs.length+1)+",";
for (var i=0; i<lesDocs.length; i++) {
listeDocuments+="\""+lesDocs[i]+"\": "+(-1*(i+1)).toString()+",";
}
var listeDocuments=listeDocuments.substring(0, listeDocuments.length-1);
listeDocuments+="\}";
eval(listeDocuments);
var bDialogue={
initialize: function(bDialogue) {
this.loadDefaults(bDialogue);
},
loadDefaults: function(bDialogue) {
bDialogue.load({
sour: listeDocuments,
fina: listeDocuments,
})
},
validate: function(bDialogue) {
var oRslt=bDialogue.store();
var docSource=bDialogue.store()["sour"];
var docFinal=bDialogue.store()["fina"];
var testOK=true;
for (var i in docSource) {
if (docSource[i]>0) {
nomSource=i;
valeurSource=listeDocuments[i];
}
}
for (var i in docFinal) {
if (docFinal[i]>0) {
nomFinal=i;
valeurFinal=listeDocuments[i];
}
}
if (valeurSource>0 || valeurFinal>0 || valeurSource==valeurFinal) var testOK=false;
if (!testOK) app.alert("Please select 2 different files to compare them.",3);
return testOK;
},
description: {
name: "Files Comparison",
elements: [
{
type: "view", //
elements: [
{
type: "view",
alignment: "align_top",
elements: [
{
type: "static_text",
name: "Source File",
font: "dialog",
bold: true,
},
{
type: "popup",
item_id: "sour",
width: 150,
},
{
type: "gap",
height: 2
},
{
type: "static_text",
name: "Final File",
font: "dialog",
bold: true,
},
{
type: "popup",
item_id: "fina",
width: 150,
},
]
},
{
type: "gap",
height: 10
},
{
type: "ok_cancel",
},
]
},
]
}
};
if("ok"==app.execDialog(bDialogue)){
var separateur="#@&";
var hauteurMP=0;
function remplacementMots(leTexte) {
return leTexte.replace(/ [^\S]+/g," ").replace(/^(\d+)$/,"$1 ").replace(/\u001E/g,"");
}
function remplacementSuites(leTexte) {
return leTexte.replace(/^\s+|\s+$/g,"").replace(/•(\d|\w)/,"• $1").replace(/[ ]{2,}/g," ");
}
function suites(leDoc) {
var lesSuites=[];
var laPage=0;
for (var p=0; p<leDoc.numPages; p++) {
var aRect=leDoc.getPageBox("Crop",p);
var basMot=aRect[1];
for (var i=0; i<leDoc.getPageNumWords(p); i++) {
var leMot=leDoc.getPageNthWord(p,i,false);
var q=leDoc.getPageNthWordQuads(p,i);
m=(new Matrix2D).fromRotated(leDoc,p);
mInv=m.invert();
r=mInv.transform(q);
r=r.toString();
r=r.split(",");
var hauteurMot=Number(r[1])-Number(r[5]);
if (!hauteurMP) var hauteurMP=hauteurMot;
var deltaHM=(hauteurMot/hauteurMP).toFixed(2);
var interligne=basMot-Number(r[5]);
if (deltaHM!=1 || (laPage==p && deltaHM==1 && interligne/hauteurMot>1.2) || /^• /.test(leMot) || (laPage!=p && /^[\w\d]/.test(leMot) && leMot.charAt(0)==leMot.toUpperCase().charAt(0))) {
lesSuites.push(remplacementMots(leMot));
} else {
lesSuites[lesSuites.length-1]+=remplacementMots(leMot);
}
if (hauteurMot!=hauteurMP) var hauteurMP=hauteurMot;
basMot=Number(r[5]);
var laPage=p;
}
}
for (var i=0; i<lesSuites.length; i++) lesSuites[i]=lesSuites[i].replace(/([\d\w])\.([^pa]|p(?!df)|a(?!i))/ig,"$1."+separateur+"$2");
for (var i=0; i<lesSuites.length; i++) {
if (lesSuites[i].indexOf(separateur)>-1) lesSuites[i]=lesSuites[i].split(separateur)
}
var suitesDecomposees=[];
for (var i=0; i<lesSuites.length; i++) {
if (typeof lesSuites[i]!="object") suitesDecomposees.push(remplacementSuites(lesSuites[i]));
else {
for (var j=0; j<lesSuites[i].length; j++) suitesDecomposees.push(remplacementSuites(lesSuites[i][j]));
}
}
return suitesDecomposees;
}
//
for (var d=0; d<openDocs.length; d++) {
if (openDocs[d].documentFileName==nomSource) suitesSource=suites(openDocs[d]);
if (openDocs[d].documentFileName==nomFinal) suitesFinal=suites(openDocs[d]);
}
function aRemplacer(leTexte) {
var lesLettres={
"ą": "a",
"ă": "a",
"ć": "c",
"ę": "e",
"ł": "l",
"ń": "n",
"ó": "o",
"ś": "s",
"ș": "s",
"ț": "t",
"ż": "z",
"ź": "z",
"Ą": "A",
"Ċ": "C",
"Ę": "E",
"Ł": "L",
"Ń": "N",
"Ó": "O",
"Ś": "S",
"Ż": "Z",
"Ź": "Z"
};
return leTexte.replace(/[ąăćęłńóśșțżźĄĊĘŁŃÓŚŻŹ]/g, function(laLettre) {return lesLettres[laLettre]});
}
var trouves=[];
for (var i=0; i<suitesSource.length; i++) {
for (var j=0; j<suitesFinal.length; j++) {
if (aRemplacer(suitesSource[i]).replace(/[^\w\d]/g,"").indexOf(aRemplacer(suitesFinal[j]).replace(/[^\w\d]/g,""))==0) {
trouves.push(suitesSource[i]);
suitesSource.splice(i,1);
suitesFinal.splice(j,1);
i--;
break;
} else {
// Vérification en retirant les caractères ascii<32
if (aRemplacer(suitesSource[i]).length==aRemplacer(suitesFinal[j]).length) {
var laSource=[];
var lefinal=[];
for (var k=0; k<aRemplacer(suitesSource[i]).length; k++) {
if (aRemplacer(suitesFinal[j]).charCodeAt(k)>31) {
laSource.push(aRemplacer(suitesSource[i])[k]);
lefinal.push(aRemplacer(suitesFinal[j])[k]);
}
}
if (laSource.toString()==lefinal.toString()) {
trouves.push(suitesSource[i]);
suitesSource.splice(i,1);
suitesFinal.splice(j,1);
i--;
break;
}
}
//
}
if (aRemplacer(suitesSource[i]).replace(/[^\w\d]/g,"").length==0) {
suitesSource.splice(i,1);
i--;
}
}
}
console.clear();
if (suitesSource.length) {
console.clear();
console.show();
console.println(suitesSource.length+" Missing information of the \""+nomSource+"\" file in the \""+nomFinal+"\" file:");
for (var i=0; i<suitesSource.length; i++) console.println("\r"+(i+1)+": "+suitesSource[i]);
console.println("\r\rComparison complete!");
app.alert("Missing information of the \""+nomSource+"\" file in the \""+nomFinal+"\" file are shown in the console window.",3);
} else {
console.hide();
app.alert("Nothing is missing, good work!",3);
}
}
}
Let me know!
@+
... View more
Jul 14, 2024
09:36 AM
Hi,
I started writing a script for comparing your files and it's progressing quite well.
While doing my tests, I realized there was a problem with some words which use special characters from your alphabet...
As shown in this screenshot, extracting these words before comparing, they are not written in the same way in your source and final files (while they are written identically in both file).
For example the word "Można" is extracted from the SourceCopy file and "Mozna" from the FinalArtwork file. So, these both words can't match...
I don't know why in the FinalArtwork file some letters are not extracted correctly! Maybe because of the font...
I will try to replace these letter while comparing words and I'll let you know...
@+
... View more
Jul 10, 2024
12:39 PM
Hi,
I was looking for an interesting exercise when I came across your request which seems to be the case.
Before starting something in the next weekend, could you let me know a couple of things.
It seems only the layout must be different between both source and final files. Is the order of texts the same in both files in the case of nothing is missing?
Should we notice the texts in addition to the final file such as these texts at the bottom of your final file?
In my opinion, it is possible to write a script that can extract the missing text. Maybe not easy... but doable.
I'll let you know on Monday...
@+
... View more
Jul 03, 2024
10:01 AM
There is a good chance that you do not need this parameter. I've been programming with Acrobat's JavaScript for a long time, and I've never used it in an actual project.
By @Karl Heinz Kremer
So I'm giving up!
Thanks
... View more
Jul 03, 2024
05:33 AM
@Karl Heinz Kremer
If I understand well, you have a script for a first dialog box...
...and an other one for a second one
The inheritDialog parameter should be able to directly recover the value of the edit text window from the first dialog box into the second one. Correct?
Where and how to place this parameter in the script of the second dialog box??? In the script below, for example (the script of the first one being the same):
var dialog={
description: {
name: "Second Dialog box",
elements: [
{
type: "view",
elements: [
{
type: "view",
alignment: "align_top",
elements: [
{
type: "edit_text",
item_id: "edtx",
width: 150,
height: 20
},
]
},
{
type: "ok_cancel",
},
]
},
]
}
};
Thanks.
@+
... View more
Jul 02, 2024
10:04 AM
I think I pretty much understand, thanks. I will try you test!
@+
... View more
Jul 02, 2024
08:52 AM
OK, thank you.
So what does mean "It is useful when displaying a series of dialog boxes..."? A series of consecutive dialog boxes (one after an other one) or elements refreshed (or new elements) in a single dialog box? And "... to prevent one from disappearing before the new one is displayed."? I never noticed that!
@+
... View more
Jul 02, 2024
06:40 AM
Hi,
Does anybody could try try to explain to me the "inheritDialog" parameter for a dialog box, and how to use it?
The API reference says :"A Dialog object that should be reused when displaying this dialog box. It is useful when displaying a series of dialog boxes (such as a wizard) to prevent one from disappearing before the new one is displayed. The default is not to reuse a dialog box."
I am doing a series of nested dialog boxes that seems to work fine (without this parameter) and I'm wondering if I need to use it. If so, how use this setting ?
Thanks in advance.
@+
... View more
Jun 22, 2024
02:30 PM
Hi, Instead of deleting the fields at the middle of your table, you can just change the values from the indice you want until the end and remove the last line...
For example, if you have 20 lines and want the delete the 15th one, all values of the 15th line will get the value onf the 16th one, all values of the 16th line will get the value onf the 17th one, ... all values of the 19th line will get the value onf the 20th one, and you remove the fields of the 20th line!
Let me know if it's not very understandable...
@+
... View more
Jun 04, 2024
01:04 AM
Hi, Here is an example for a stamp with a dropdown and a quick script:
var theItems=["item #1","item #2","item #3","item #4","item #5"];
var theField="- Select an Item -";
var theList="var theList \= \{\""+theField+"\": "+(theItems.length+1)+",";
for (var i=0; i<theItems.length; i++) {
var itemName=theItems[i];
theList+="\""+itemName+"\": "+(-1*(i+1)).toString()+",";
}
var theList=theList.substring(0,theList.length-1);
theList+="\}";
eval(theList);
var dialogBox={
initialize: function(dialogBox) {
this.loadDefaults(dialogBox);
},
loadDefaults: function(dialogBox) {
dialogBox.load({
LCha: theList,
})
},
validate: function(dialogBox) {
var oRslt=dialogBox.store();
var elements=dialogBox.store()["LCha"];
var testOK=true;
for (var i in elements) {
if (elements[i]>0) {
listValue=theList[i];
listName=i;
}
}
if (listValue>0) var testOK=false;
if (!testOK) app.alert("Please select an item",3);
return testOK;
},
description: {
name: "Stamp with Dropdown",
elements: [
{
type: "view",
elements: [
{
type: "view",
alignment: "align_fill",
elements: [
{
type: "static_text",
name: "Items",
font: "dialog",
bold: true,
},
{
type: "popup",
item_id: "LCha",
width: 150,
alignment: "align_fill",
},
]
},
{
type: "gap",
height: 5
},
{
type: "ok_cancel",
},
]
},
]
}
};
if (event.source.forReal && event.source.stampName=="#bebarth") {
if("ok"==app.execDialog(dialogBox)){
event.value=listName;
}
}
@+
... View more
May 23, 2024
11:45 AM
Sorry but I don't understand ! This page should be Page 1???
... View more