bebarth
Community Expert
bebarth
Community Expert
Activity
Apr 04, 2025
12:58 PM
Here is my script. Whether it is faster, I do not know. Because I can't test Acrobat's own split function against my script. I use it on purchased digital stamps that I use for postal mailings. These PDFs can contain up to 10,000 pages. generateSinglePages = app.trustedFunction(function () {
d0 = new Date();
debut = util.printd("dd/mm/yyyy, HH:MM", d0);
// Regular expression used to acquire the base name of file
var re = /.pdf$/i;
var filename = this.documentFileName.replace(re, ""); // filename is the base name of the file Acrobat is working on
var npath = this.path.slice(0, this.path.length - (filename.length + 4));
try {
var t = app.thermometer;
t.duration = this.numPages;
t.begin();
for (var i = 0; i < this.numPages; i++) {
console.clear();
console.println("Process Starting: " + debut);
console.println("Page ") + (i + 1);
var nummer = util.printf("%05d", (i * 1 + 1) + ""); // The numbering is zeroed out to five digits.
this.extractPages
({
nStart: i,
cPath: npath + filename + "_" + nummer + ".pdf"
});
t.value = i;
t.text = 'Save page ' + i + ' as file ' + filename + '_' + nummer + '.pdf';
if (t.cancelled)
break;
}
t.end();
} catch (e) {
app.alert("An error has occurred: " + e.message);
}
df = new Date();
fin = util.printd("dd/mm/yyyy, HH:MM", df);
temps = (df.valueOf() - d0.valueOf()) / 1000 / 60;
var lesMinutes = parseInt(temps);
var lesSecondes = (temps - lesMinutes) * 60;
var lesSecondes = parseInt(lesSecondes * 10) / 10;
var leTemps = "";
if (lesMinutes > 0) {
if (lesMinutes == 1) {
var leTemps = "1 minute";
} else {
var leTemps = lesMinutes + "minutes";
}
}
if (lesSecondes > 0) {
if (lesSecondes < 2) {
var leTemps = leTemps + " " + lesSecondes + " second";
} else {
var leTemps = leTemps + " " + lesSecondes + " seconds";
}
} else
var leTemps = "Less than 1 second";
var leTemps = leTemps.replace(/^\s+|\s+$/gm, "");
console.clear();
console.println("Process Starting: " + debut);
console.println("Process Ending: " + fin);
console.println("––––––––––––––");
console.println("Process Duration: " + leTemps + " for extracting " + this.numPages + " pages");
})
generateSinglePages()
... View more
Apr 01, 2025
05:39 AM
1 Upvote
Hi,
Try this script I wrote some years ago from the console window:
function triSignets(signet) {
if (signet.children!=null) {
signet.open=true;
var leSignet=signet.children;
lesSignets=[];
for (var i=0; i<leSignet.length; i++) lesSignets.push(leSignet[i].name);
lesSignets=lesSignets.sort(function(a,b){return a.localeCompare(b)});
for (var i=0; i<lesSignets.length; i++) {
for (j=0; j<leSignet.length; j++) {
if (lesSignets[i]==leSignet[j].name) {
signet.insertChild(leSignet[j],i);
break;
}
}
}
if (leSignet!=null) {
for (var i=0; i<leSignet.length; i++) triSignets(leSignet[i]);
}
}
}
triSignets(this.bookmarkRoot);
@+
... View more
Mar 29, 2025
06:39 AM
hé la la!! merci merci merci! ça fonctionne!!!!
... View more
Mar 25, 2025
12:34 PM
wow, well done, thank you!
... 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:23 AM
Not sure to understand your request! What do you mean exactly?
@+
... View more
Mar 04, 2025
05:35 AM
"Use Adobe Acrobat with french UI."
Bernd Alheit, unfortunately, the French version of Acrobat does not correctly respect the French date format. This is a “bug” I've been reporting for over 20 years, but apparently the development team doesn't care.
... View more
Feb 21, 2025
01:47 PM
[MOVED TO THE ACROBAT DISCUSSIONS]
... View more
Jan 30, 2025
05:11 PM
In a validate script the value of the newly selected item is in "event.value". Your scripts are using getField to acquire the field the script is in. This gets the previosly selected value, because the field value doesn't change until after validation is complete.
However, if you really wanted the field object, it is in event.target. So no need to use the getField function.
... View more
Jan 24, 2025
09:02 AM
Hi, Try editing an image with Adobe Express's new feature: https://adobe.ly/40uKLmX; Let us know if that solves your problem. Note: This feature is currently available with the latest version of Acrobat Pro DC and is available if you have New Acrobat enabled.
Let us know if you have further questions.
~Tariq
... View more
Oct 08, 2024
06:50 AM
1 Upvote
On Windows it's Ctrl and/or AltGr.
... View more
Oct 06, 2024
04:03 AM
1 Upvote
obviously! Works fine, 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
Jul 30, 2024
04:08 PM
Have you tested the script?
By @Bernd Alheit
That "user" is an AI spam bot.
... 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 16, 2024
01:58 PM
Complicating things for you is that your text encoding is different in both files, so a lot of your alternative languages using accents and extra glyphs will not match.
... 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
May 23, 2024
12:19 PM
I did it thank you var emptyFields = [];
var maxAlerts = 10; // Max fields indicated in the alert box
var fieldsMap = {}; // Map to store the field name associated with each tooltip text
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") {
var tooltipText = f.userName || "Field \"" + f.name + "\"";
fieldsMap[tooltipText] = fname; // Store the field name associated with the tooltip text
emptyFields.push({ tooltip: tooltipText, name: fname });
}
}
} else {
break;
}
}
if (emptyFields.length > 0) {
emptyFields.sort(function(a, b) {
// Extract page numbers from tooltip texts and compare them numerically
var pageA = parseInt(a.tooltip.match(/Page (\d+)/)[1], 10);
var pageB = parseInt(b.tooltip.match(/Page (\d+)/)[1], 10);
return pageA - pageB;
});
var message = "Please fill in the following required field(s):\n\n" + emptyFields.map(function(field) {
return field.tooltip;
}).join("\n");
// Display the alert with the sorted tooltip texts
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
});
// Get the field name for the first sorted tooltip text
var firstField = emptyFields[0].name;
if (firstField) {
this.getField(firstField).setFocus();
}
}
... View more
May 22, 2024
04:42 AM
It would be generous to call me a beginner when it comes to scripting, so I must admit I felt a bit lost with your first answer. I really really appreciate the lengthy, clear, and specific help here. Thank you very much! I will attempt it and get back on the results.
... View more
May 10, 2024
10:48 AM
Hi, I'm having this same issue, but the keystroke script is not working. I think it's because I don't have an person typing in the form, but rather the data is being mapped to fields from smartsheet. Is there a script that would work in the Format section instead of the Keystroke section?
... View more
May 06, 2024
11:03 AM
It was like a nightmare for me to extract highlighted texts from pdf files.. I tried making it with code but later on discovered readoku.com where you can export highlights into word, excel, json and csv file formats. In case anyone still searching a time saving way..
... 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
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 10, 2024
06:30 AM
@bebarth it worked! I fixed date fromating issue that was preventing the calculation to work on the DOI and Sx dates. Thank you much!
... View more
Apr 08, 2024
01:14 PM
Did you find the Acrobat stamps folder?
... 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 24, 2024
03:31 PM
You'll find loads of tutorials and samples here:
https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm
... View more