bebarth
Community Expert
bebarth
Community Expert
Activity
‎May 23, 2024
11:45 AM
Sorry but I don't understand ! This page should be Page 1???
... View more
‎May 23, 2024
10:29 AM
Hi,
I added a few lines between "BB Start" and "BB End".
function getPageNumForField(field) {
// No longer used, can be removed
// return field.page + 1; // Convert from 0-based to 1-based indexing
}
var emptyFields = [];
var maxAlerts = 10; // Max fields indicated in the alert box
var currentPage = this.pageNum; // Save the current page number (not used)
var firstField = null;
for (var i = 0; i < this.numFields; i++) {
if (emptyFields.length < maxAlerts) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if (f.type !== "button" && f.required === true) {
if (f.value === "" || f.value === "Off") {
if (!firstField) firstField = fname; // Save the first empty field name
if (f.userName) {
emptyFields.push(f.userName);
} else {
emptyFields.push("Field \"" + f.name + "\"");
}
}
}
} else {
break;
}
}
if (emptyFields.length > 0) {
// BB Start
for (var i=0; i<emptyFields.length; i++) emptyFields[i]=[emptyFields[i],Number(emptyFields[i].substring("Page ".length,emptyFields[i].indexOf("-")))];
emptyFields.sort(function(a, b){return a[1]-b[1]});
for (var i=0; i<emptyFields.length; i++) emptyFields[i].pop();
// BB End
var message = "Please fill in the following required field(s):\n\n" + emptyFields.join("\n");
// **Assuming app.alert supports tooltips (modify as needed):**
app.alert({
cMsg: message,
cTitle: "Required Fields Check",
nIcon: 3, // Optional: set icon type (3 for warning icon)
nType: 0 // Optional: set type to OK button only
});
if (firstField) {
this.getField(firstField).setFocus();
}
}
// No longer needed as page number is not used
// this.pageNum = currentPage;
Please try and let me know...
@+
... View more
‎May 21, 2024
01:59 PM
Here is my proposal I did (I was waiting for an answer of the requester). you have to create an action wizard with this script:
var otherDoc=app.openDoc("Specifications.pdf",this);
otherDoc.getField("title").value=this.info.Title;
otherDoc.getField("fileName").value=this.documentFileName;
otherDoc.getField("date").value=util.printd("dd-mm-yyyy",new Date());
otherDoc.getField("project").value="No found on the document!";
otherDoc.getField("frontPage").buttonImportIcon(this.path);
var pt2mm=25.4/72;
var aRect=this.getPageBox();
otherDoc.getField("dimensions").value=(Number(aRect[2])*pt2mm).toFixed(1)+" x "+(Number(aRect[1])*pt2mm).toFixed(1)+" mm";
otherDoc.getField("nbPages").value=this.numPages;
var p=this.numPages-1;
for (var i=0; i<this.getPageNumWords(p); i++) {
console.println("OK : "+this.getPageNthWord(p, i, true));
try {
if (this.getPageNthWord(p, i, true)=="No" && this.getPageNthWord(p, i+1, true)=="Publication") {
otherDoc.getField("article").value=this.getPageNthWord(p, i+2, true);
} else if (this.getPageNthWord(p, i, true)=="Edition") {
otherDoc.getField("edition").value=this.getPageNthWord(p, i+1, true)+" "+this.getPageNthWord(p, i+2, true);
break;
}
} catch(e) {}
}
otherDoc.saveAs({
cPath: otherDoc.path.replace(/.pdf$/i," ("+this.info.Title+" - "+util.printd("dd mmmm yyyy",new Date())+").pdf"),
});
this.closeDoc();
Specification and publications files are in the same folder for this example.
Open a publication file.
Click on the action wizard tools then click on the one you created.
Add all other publication files you need to generate a specification file.
Then click on "Start". The action will generate all specification files.
The script must be adapted in accordance with real needs and real layout of the publication files...
@+
... View more
‎May 21, 2024
12:04 PM
1 Upvote
For the tooltip, use the userName property!
@+
... View more
‎May 21, 2024
09:10 AM
1 Upvote
Here is a shorter script where you can indicate the max number of fields to indicate in the alert box.
var maxAlerts=10; // Max fields indicated in the alert box
var emptyFields=[];
for (var i=0; i<this.numFields; i++) {
if (emptyFields.length<maxAlerts) {
var f=this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required==true) {
if (f.value=="" || f.value=="Off") {
if (!emptyFields.length) var firstField=this.getNthFieldName(i);
var thisPage=this.getPageLabel(f.page);
if (f.userName) emptyFields.push(f.userName);
else emptyFields.push("Page "+thisPage+": "+"Field \""+f.name+"\"");
}
}
} else break;
}
if (emptyFields.length) {
var message="Please fill in the following required field(s):\n\n"+emptyFields.toString().replace(/,/g, "\r");
app.alert({
cMsg: message,
cTitle: "Required Fields Check",
nIcon: 3
});
this.getField(firstField).setFocus();
}
Let me know.
@+
... View more
‎May 21, 2024
05:52 AM
1 Upvote
Hi,
Try that:
var emptyFields = [];
var currentPage = this.pageNum;
for (var i = 0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if (f.type !== "button" && f.required === true) {
if (f.value === "" || f.value === "Off") {
var pageNum = getPageNumForField(f); // Call the function to get page number
if (f.userName) emptyFields.push(f.userName);
else emptyFields.push("Page " + pageNum + ": " + "Field " + f.name);
}
}
}
if (emptyFields.length > 0) {
var message = "Please fill in the following required field(s):\n\n" + emptyFields.join("\n");
// Use a timeout to delay the alert
app.setTimeOut(function() {
app.alert({
cMsg: message,
cTitle: "Required Fields Check",
nIcon: 3, // Optional: set icon type (3 for warning icon)
nType: 0 // Optional: set type to OK button only
});
// Restore the original page number after the alert
this.pageNum = currentPage;
}.bind(this), 10); // Bind 'this' to ensure the correct context
}
function getPageNumForField(field) {
return this.getPageLabel(field.page);
}
@+
... View more
‎May 04, 2024
05:39 AM
Hi,
Where are located both front and back pages?
If they are on a sever disk the path is the same for all users. If they are in local, instead of creating a new doc, you can open
one of them then add the other one and save the combined file with a new name... (is this understandablle???).
@+
... View more
‎May 02, 2024
02:53 AM
1 Upvote
Hi, That is possible runing a wizard action from the publication file which will fill the specification file.
@+
... View more
‎Apr 24, 2024
12:49 PM
It's explained above, you create an action wizard and you add files...
@+
... View more
‎Apr 20, 2024
02:52 PM
Yes, of course!
... View more
‎Apr 20, 2024
01:59 PM
Hi, To use Segoe UI font, you must write:
...
cFont: SegoeUI,
...
For the text, you can split the file name without the .pdf extension in a table with:
var bothTexts=this.documentFileName.substr(0,this.documentFileName.length-4).split(" ");
then you will use the first element of the table bothTexts[0] if you want to use the number or the second one bothTexts[1] if you prefer the text.
...
cText: bothTexts[0], // or bothTexts[1]
...
@+
... View more
‎Apr 19, 2024
09:02 AM
1 Upvote
Hi,
I have a script running from the console window or an action wizard. This script merge several other files in a one then save it in a folder.
This script works fine on Mac but give an error message on PC (Windows 10).
I found several posts proposing to unselect the "Preview Pane" of the file explorer like this one:
https://community.adobe.com/t5/acrobat-discussions/error-the-file-may-be-a-read-only-or-another-user-has-it-open/m-p/9544011#M81038
...but that doesn't work for me.
Note that I am able to save a file in the adequat folder via the Acrobat menu.
Do you have any idea where this could come from?
Thanks
... View more
‎Apr 09, 2024
08:30 AM
Hi,
Attached is your file which should work correctly! Let me know...
@+
... View more
‎Apr 08, 2024
01:40 PM
Sorry, I can't help you right now because I don't have my computer.... only my phone!
I will have a look on your file tomorrow.
@+
... View more
‎Apr 08, 2024
01:14 PM
Did you find the Acrobat stamps folder?
... View more
‎Apr 08, 2024
10:14 AM
Hi,
Attached is your stramps file you must place in the stamps folder of the computer of each user. To find the path of this folder, execute the following script from the console window:
app.getPath("app", "stamps");
Then you quit and re-launch the Acrobat application.
In your stamps you will find an "All Stamps" group containing all your stamps.
You can now use the one you wish, it will indicate the stamp name, the user name and the dat and time.
Let me know if that suits you or if you need any modifications!
@+
... View more
‎Apr 08, 2024
03:53 AM
If I understand well, you need these 6 stamps with on each one:
The stamp name
The user name
The date (and time)
Correct?
@+
... View more
‎Apr 07, 2024
12:00 PM
Hi,
What do you want exactly as fields on your stamp?
@+
... View more
‎Mar 29, 2024
10:00 AM
Hi,
Sorry, I didn't notice your request!
Attached is an example with this script for the "SAVE AS" button:
if (/^[a-zA-Z0-9]+$/.test(this.getField("orderNumber").value)) {
try {
Save_orderNumber(this.path.substr(0,this.path.lastIndexOf("/")+1)+this.getField("orderNumber").value+".pdf");
this.resetForm();
} catch(e) {
this.getField("theScript").display=display.visible;
app.alert("The \"austin36331818118t.js\" file is not installed on this computer.");
}
} else app.alert("Please enter a correct Order Number");
this.dirty=false;
For working, you must place a .js file in the JavaScript Acrobat folder of each computer. You can name it as you want but it must contain this script:
Save_orderNumber=app.trustedFunction(function(newFilePath) {
app.beginPriv();
this.saveAs({
cPath: newFilePath,
bCopy: true,
bPromptToOverwrite: true
});
app.endPriv();
})
Here, the new file will be saved in the same folder as the original file.
You can modify the condition of your order number or the parameters method.
@+
... View more
‎Mar 26, 2024
09:36 AM
OK, Thanks!
... View more
‎Mar 26, 2024
07:10 AM
Hi,
It's only possible if you write an application script, that means you will have to place a .js file in local on the computer of each user.
@+
... View more
‎Mar 26, 2024
06:04 AM
2 Upvotes
Hi,
I think I understood the nPos parameter of the app.addMenuItem method, and if several scripts have the same parameter the last item loaded take the place of the previous one.
But I wonder in which order the different .js files of the "JavaScript" folder are loaded to know which is the last one and see if it actually takes the last position indicated. I did several tests and it seems it's not the alphabetical order...
Thanks.
@+
... View more
‎Mar 24, 2024
11:29 AM
Fair warning, maybe I'm missing something - fairly new at this!
By @Laura356523064few
Certainly!
@+
... View more
‎Mar 24, 2024
03:34 AM
Hi,
If you don't konw exactly the number of fields or if all indices are not consecutive, you can directly write this script which will find the indice:
var ind=event.target.name.substr("TotalRow".length);
var hour=this.getField("HoursRow"+ind).value;
var cost=this.getField("RateRow"+ind).value;
if (hour && cost) event.value=hour*cost;
else event.value="";
You can also use a function in document level:
function myFunction(ind) {
var hour=this.getField("HoursRow"+ind).value;
var cost=this.getField("RateRow"+ind).value;
if (hour && cost) return hour*cost;
else return "";
}
and call it with this script:
event.value=myFunction(event.target.name.substr("TotalRow".length));
And if you have a lot of " TotalRow" fields, you can write the call script in all these fields runing this following script from the console window:
for (var i=0; i < this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("TotalRow")==0) this.getField(this.getNthFieldName(i)).setAction("Calculate","event.value=myFunction(event.target.name.substr(\"TotalRow\".length));");;
}
That's all folks
8-)
... View more
‎Mar 19, 2024
03:30 AM
Hi, This should be possible with a script executable from an action wizard, but this would require seeing what exactly the different documents are like in order to be able to consider programming... @+
... View more
‎Mar 02, 2024
09:29 AM
Hi try67,
As you suggested I did a test removing the resetForm command, but that didn't work very well when the user write too quickly.... so I kept it.
I solved the first problem by reducing the number indicated for each line by 1 character. Indeed, when the fieldFull state is at 1 the maxi number of characters is the number preceding this change of state. This works well, but in this same case I still have a loss of the first character if the user types too quickly...
For the problem of modification in the middle of the text, I am still looking for a good solution. I had the idea to change "doNotScroll" to false if (event.selStart<leTexte.length && event.selEnd<leTexte.length) but that doesn't work very well... If you have an idea!
Attached is my last example file.
Thanks & @+
... View more
‎Feb 27, 2024
10:53 AM
In a few words:
longueurLignes is a table incremented after each "fieldFull" state that indicated the number of characters from the begining of the text until the end of each line.
ligneNo is the number of lines. It could be longueurLignes.length that would avoid ligneNo++ and ligneNo--.
reduireHauteur is a flag (0 or 1) that allows reducing the height of the field.
Take your time...
@+
... View more
‎Feb 27, 2024
10:17 AM
Hi,
Here is a first working file I did rather quickly, but I am locked with few problems for a couple of days.
It seems that works pretty fine when modifications are done from the end of the text except when we add a new character just after the last one following the "fieldFull" flag.
Example in my attached file:
If I delete the "d" character
then I re-add it, the field becomes blank
while if you delete the "d" then the "l"
you can continue typing correctly
An other problem is when we add some charaters a the middle of the text field. At the next "fieldFull" flag the cursor comes back at the end of the text, so it's not possible to directly continue the typing...
If you have an idea!!!
Let me know if you think these are problems that can be solved...
I hope you will understand my logic!
Ps: You can take your time 😉 I will not able to take care of that for few days;
@+
... View more
‎Feb 24, 2024
03:09 PM
Here is a file with my mage and your mask.
@+
... View more
‎Feb 24, 2024
12:44 PM
Could you please share your png file?
@+
... View more