bebarth
Community Expert
bebarth
Community Expert
Activity
‎Dec 02, 2023
12:33 AM
1 Upvote
Hi,
Nesa's answer is correct, simple and seems to suit you. As it is said, the annotation text box can be blocked, but it must be unblocked to be able to change the price or do it via a scrpt. To finish with my version with annotations, and for those who are interested, I suggest to you a transparent button placed above the "QUICK STEP" sign.
A script is executed when you press this button and brings up a dialog box where you can only indicate a price, different from the one already indicated, then replaces the price displayed without having to unlock the annotation block.
Here is the script ran:
this.syncAnnotScan();
var annots=this.getAnnots();
if (annots!=null) {
for (var i=0; i<annots.length; i++) {
if (annots[i].type=="FreeText") {
var price=annots[i].contents;
while (price==annots[i].contents || isNaN(price.toString().replace(/[,]/,"."))) {
var price=app.response({
cQuestion: "What is the new price?",
cTitle: "PRICE",
cLabel: "New Price:",
cDefault: annots[i].contents
});
}
annots[i].delay=true;
var textAttributs=annots[i].richContents;
var spans=new Array();
spans[0]=new Object();
spans[0].alignment=textAttributs[0].alignment;
spans[0].fontFamily=textAttributs[0].fontFamily;
spans[0].fontStretch=textAttributs[0].fontStretch;
spans[0].fontStyle=textAttributs[0].fontStyle;
spans[0].fontWeight=textAttributs[0].fontWeight;
spans[0].strikethrough=textAttributs[0].strikethrough;
spans[0].subscript=textAttributs[0].subscript;
spans[0].text=price;
spans[0].textColor=textAttributs[0].textColor;
spans[0].textSize=textAttributs[0].textSize;
spans[0].underline=textAttributs[0].underline;
annots[i].richContents=spans;
annots[i].delay=false;
}
}
}
This script assumes that there is only one text box but can be adapted if there are several ones. All text attributes are re-placed but in your case you don't need all of them...
Why make it simple when you can make it complicated ! 🙂
@+
... View more
‎Dec 01, 2023
05:22 AM
Hi,
I don't have the right font here, but you could replace the price field by a text box annotation where you can modify the text font and color and the color of the background to be the same as the rectagle stamp.
and the result (with a wrong font):
and you can modify the price directly from the annotation window.
@+
... View more
‎Dec 01, 2023
04:44 AM
Of course, the request was "add a blank page after pas 1 and 3", which assumes there are at least 3 pages in the document 😉
@+
... View more
‎Dec 01, 2023
03:56 AM
Hi, Maybe I didn't understand your request, but for me that works fine...
@+
... View more
‎Nov 30, 2023
05:50 PM
Hi,
For adding a blank pages after both of these one you can run this script fron the console window:
for (var p=2; p>=0; p-=2) {
var pageBox=this.getPageBox("Crop",p);
this.newPage(p+1,pageBox[2],pageBox[1]);
}
@+
... View more
‎Nov 30, 2023
05:34 PM
Hi,
If you remove the background of both fields and create a white rectangle stamp, you can do something close to what you want...
@+
... View more
‎Nov 30, 2023
05:03 PM
1 Upvote
Hi,
And unfortunately with the "Find" tool, you will have to click 200 times the "Replace Next" button... unless the latest Acrobat version includes a "Change All" option!
@+
... View more
‎Nov 30, 2023
04:21 PM
Hi,
Instead of, you can use this function:
function trunc(x) {
return Number(x.toString().substr(0,x.toString().indexOf(".")));
};
@+
... View more
‎Nov 30, 2023
12:02 PM
1 Upvote
Apparently all hyperbolic functions don't work! If you're interested, here are the associated functions:
//********
// cosh **
//********
function cosh(x) {
return (Math.exp(x)+Math.exp(-x))/2;
};
//*********
// acosh **
//*********
function acosh(x) {
return Math.log(x+Math.sqrt(Math.pow(x,2)-1));
}
//********
// sinh **
//********
function sinh(x) {
return (Math.exp(x)-Math.exp(-x))/2;
};
//*********
// asinh **
//*********
function asinh(x) {
if (x===-Infinity) return x;
else return Math.log(x+Math.sqrt(Math.pow(x,2)+1));
}
//********
// tanh **
//********
function tanh(x) {
var a=Math.exp(+x);
var b=Math.exp(-x);
return a==Infinity?1:b==Infinity?-1:(a-b)/(a+b);
};
//*********
// atanh **
//*********
function atanh(x) {
return Math.log((1+x)/(1-x))/2;
};
@+
... View more
‎Nov 30, 2023
01:03 AM
3 Upvotes
Hi,
Unless I'm mistaken, I just realized that the Math.acosh() Javascript method doesn't work with Acrobat. So I recreated it with a function:
function acosh(x) {
return Math.log(x+Math.sqrt(Math.pow(x,2)-1));
}
Has anyone heard of this and know why? Are there other Math methods that don't work?
Thanks
@+
... View more
‎Nov 29, 2023
04:18 PM
2 Upvotes
Here is my proposal.
Open your first form.
The first time, you will have to create the action wizard.
Then give a name to your action.
and it will appear at the top of the list.
Click on the action wizard then on "Add Files...". If all your forms are in a same folder, you can click "Add Folder..."
Select all the files you want to modify then click "Start"
All the files will be modifyed. The selected item of each file will be kept if it still exist.
The script to paste for the action wizard is:
var fieldName="NameLicense";
try {
var selectedItem=this.getField(fieldName).value;
this.getField(fieldName).setItems(["- Select a Name -","Daniela Barros – 111222", "Marcel Short – 222333", "Mary Stal – 444555"]);
try {
this.getField(fieldName).value=selectedItem;
} catch(e) {};
this.saveAs(this.path);
} catch(e) {
app.alert("The dropdown field \""+fieldName+"\" doesn't exist on this form.",2);
}
I hope that will help you...
@+
... View more
‎Nov 29, 2023
01:07 PM
The dropdown fields have the same name in all the forms?
Do you know how action wizards operate?
Could you give me an example of the items (and export values) for the dropdown field... and its name!
@+
... View more
‎Nov 29, 2023
12:12 PM
1 Upvote
Hi,
If the drop-down list field has the same name on all forms, it's possible to write an JavaScript action wizard to modify all the forms.
@+
... View more
‎Nov 27, 2023
06:12 AM
2 Upvotes
Hi,
... Your file works fine, just update of list items in the succeeding dropdowns does not happen instantly. By @Khalid Khan
Sorry, you must tick "Commit selected value immediately" as option for all the dropdown fields. I forgot to do it in my prvious example file. Attached is a new one which should work better...
@+
... View more
‎Nov 25, 2023
01:07 PM
2 Upvotes
Hi,
Here is an example for a set of drowpdown fields with a same name including an index. In the example file, this script is included in a function which is recalled by a "Mouse Enter" Action script: fillDropdown();
function fillDropdown() {
var theItems=["Item A","Item B","Item C","Item D","Item E","Item F","Item G","Item H","Item I","Item J"];
var dropdownName="Dropdown";
var dropdownNumber=5;
var theIndex=event.target.name.substr(event.target.name.indexOf(".")+1);
var theValue=event.target.value;
for (var i=0; i<dropdownNumber; i++) {
if (i!=theIndex) {
for (j=0; j<=theItems.length; j++) {
if (theItems[j]==this.getField(dropdownName+"."+i).value) {
theItems.splice(j,1);
break;
}
}
}
}
theItems.unshift("- Select an Item -");
event.target.setItems(theItems);
event.target.value=theValue;
}
If the name of each field is not consistent, the script can be be modifyed and names placed in an other array!
@+
... View more
‎Nov 17, 2023
12:33 PM
Hi,
I used the standard settings...
@+
... View more
‎Nov 16, 2023
12:12 PM
Hi, In fact, you have to launch the OCR before runing the script.
On your invoices, sometime there is a space between "No." and the ":" symbol and sometime there is no space.
I modifyed a bit the script for catching both configurations and I found 60 invoices separated from your original example. Please check if this number is correct!
Here is the script:
console.show();
console.clear();
d0=new Date();
debut=util.printd("dd-mm HH:MM",d0);
laDate=util.printd("dd-mm-yy",d0);
var invoices=[];
for (var p=0; p<this.numPages; p++) {
console.clear();
console.println("Process Starting: "+debut);
console.println("––––––––––––––");
console.println("Invoice number searching on page "+(p+1));
console.println(invoices.length+" invoices found");
var nbWords=this.getPageNumWords(p);
for (var i=0; i<nbWords-1; i++) {
if (this.getPageNthWord(p, i, false).indexOf("No.:")==0 && !isNaN(this.getPageNthWord(p, i+1, true)) && this.getPageNthWord(p, i+1, true).length==6) {
invoices.push([p,this.numPages-1,this.getPageNthWord(p, i+1, true)]);
if (invoices.length>1) invoices[(invoices.length-2)][1]=(p-1);
break;
} else if (this.getPageNthWord(p, i, false).indexOf("No.")==0 && this.getPageNthWord(p, i+1, false).indexOf(":")==0 && !isNaN(this.getPageNthWord(p, i+2, true)) && this.getPageNthWord(p, i+2, true).length==6) {
invoices.push([p,this.numPages-1,this.getPageNthWord(p, i+2, true)]);
if (invoices.length>1) invoices[(invoices.length-2)][1]=(p-1);
break;
}
}
}
var newPath=this.path.replace(this.documentFileName,"New Documents/");
for (var i=0; i<invoices.length; i++) {
console.clear();
console.println("Process Starting: "+debut);
console.println("––––––––––––––");
console.println("Extracting invoice number "+invoices[i][2]);
this.extractPages({
nStart: invoices[i][0],
nEnd: invoices[i][1],
cPath: newPath+invoices[i][2]+".pdf"
})
}
df=new Date();
fin=util.printd("dd-mm 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"
}
}
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);
console.println(invoices.length+" invoices extracted.");
I'll send you by e-mail the file after the OCR, which one I worked with...
@+
... View more
‎Nov 13, 2023
05:14 AM
1 Upvote
Je confirme !!!
@+
... View more
‎Nov 10, 2023
03:46 AM
Hi,
It's quite difficult to know why that doesn't work for you. I did a test with a fictive file and it worked fine. Is it possible for you to share a file or an abstract in PM? I'll have a look.
@+
... View more
‎Nov 09, 2023
02:47 PM
Try this script:
var invoices=[];
for (var p=0; p<this.numPages; p++) {
var nbWords=this.getPageNumWords(p);
for (var i=0; i<nbWords-1; i++) {
var theWord=this.getPageNthWord(p, i, false);
var nextWord=this.getPageNthWord(p, i+1, true);
if (theWord.indexOf("No.")==0 && !isNaN(nextWord) && nextWord.length==6) {
invoices.push([p,this.numPages-1,nextWord]);
if (invoices.length>1) invoices[(invoices.length-2)][1]=(p-1);
break;
}
}
}
// Files Extracting
var newPath=this.path.replace(this.documentFileName,"New Documents/");
for (var i=0; i<invoices.length; i++) {
this.extractPages({
nStart: invoices[i][0],
nEnd: invoices[i][1],
cPath: newPath+invoices[i][2]+".pdf"
})
}
If there are a lot of text on each page, the process can be quite long. So here is the same script with display of the progress of the process in the console window:
console.show();
console.clear();
d0=new Date();
debut=util.printd("dd-mm HH:MM",d0);
laDate=util.printd("dd-mm-yy",d0);
var invoices=[];
for (var p=0; p<this.numPages; p++) {
console.clear();
console.println("Process Starting: "+debut);
console.println("––––––––––––––");
console.println("Invoice number searching on page "+(p+1));
var nbWords=this.getPageNumWords(p);
for (var i=0; i<nbWords-1; i++) {
var theWord=this.getPageNthWord(p, i, false);
var nextWord=this.getPageNthWord(p, i+1, true);
if (theWord.indexOf("No.")==0 && !isNaN(nextWord) && nextWord.length==6) {
invoices.push([p,this.numPages-1,nextWord]);
if (invoices.length>1) invoices[(invoices.length-2)][1]=(p-1);
break;
}
}
}
var newPath=this.path.replace(this.documentFileName,"New Documents/");
for (var i=0; i<invoices.length; i++) {
console.clear();
console.println("Process Starting: "+debut);
console.println("––––––––––––––");
console.println("Extracting invoice number "+invoices[i][2]);
this.extractPages({
nStart: invoices[i][0],
nEnd: invoices[i][1],
cPath: newPath+invoices[i][2]+".pdf"
})
}
console.println("––––––––––––––");
df=new Date();
fin=util.printd("dd-mm HH:MM",df);
console.println("Process Ending: "+fin);
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"
}
}
var leTemps=leTemps.replace(/^\s+|\s+$/gm,"");
console.clear();
console.println("Process Starting: "+debut);
console.println("––––––––––––––");
console.println("Process Duration: "+leTemps);
console.println(invoices.length+" invoices extracted.");
Let me know.
@+
... View more
‎Nov 09, 2023
09:31 AM
OK, I'll write a script for you this evening.
@+
... View more
‎Nov 09, 2023
08:33 AM
...and this number is indicated on each page of the same invoice? ...or only on the first page?
Is it always a 6-digit number, or it can be from 4 to 8-digit (for example)?
@+
... View more
‎Nov 09, 2023
07:37 AM
If the invoice number is always located at the same place or always after the "No." text, we can use an other script.
Is it the case?
@+
... View more
‎Nov 09, 2023
06:32 AM
No answer!!!
Well, let's imagine that we created a "New Documents" directory in the same folder as the main file for saving all new documents. The pages extracted will be from the page number relative to the bookmark to the previous page number relative to the next bookmark. The script is as follows:
// Only Lowest-Level Bookmarks At The Root Level
lowestLevelBookmarks=[];
function lowestLevelBookmarksAtTheRootLevel(bkm,nLevel) {
if (bkm.name!="Root" && bkm.children==null) {
bkm.execute();
lowestLevelBookmarks.push([bkm.name,this.pageNum]);
}
if (bkm.children!=null) for (var i=0; i<bkm.children.length; i++) lowestLevelBookmarksAtTheRootLevel(bkm.children[i],nLevel+1);
}
lowestLevelBookmarksAtTheRootLevel(this.bookmarkRoot,0);
bookmarkRoot.remove();
for (var i=lowestLevelBookmarks.length-1; i>=0; i--) this.bookmarkRoot.createChild(lowestLevelBookmarks[i][0],"this.pageNum="+lowestLevelBookmarks[i][1]);
// Main File Saving
var newPath=this.path.replace(this.documentFileName,"New Documents/");
this.saveAs(newPath+this.documentFileName.replace(/.pdf$/i," \(Only Lowest Bookmarks\).pdf"));
// Files Extracting
for (var i=0; i<lowestLevelBookmarks.length; i++) {
var statingPage=lowestLevelBookmarks[i][1];
if (i<lowestLevelBookmarks.length-1) var endingPage=lowestLevelBookmarks[i+1][1];
else var endingPage=this.numPages-1;
if (endingPage>statingPage && endingPage!=this.numPages-1) endingPage--;
this.extractPages({
nStart: statingPage,
nEnd: endingPage,
cPath: newPath+lowestLevelBookmarks[i][0].replace(/\s+/g," ").replace(/\s+$/,"")+".pdf"
})
}
@+
... View more
‎Nov 08, 2023
03:36 PM
If you know the new path there is no problem to save the file with new bookmarks in an other folder.
For splitting the file I still don't know the ranges of page you want as asked previously.
@+
... View more
‎Nov 08, 2023
02:20 PM
Hi,
Here is a script which will generate all lowest bookmarks at the first root level:
lowestLevelBookmarks=[];
function lowestLevelBookmarksAtTheRootLevel(bkm,nLevel) {
if (bkm.name!="Root" && bkm.children==null) {
bkm.execute();
lowestLevelBookmarks.push([bkm.name,this.pageNum]);
}
if (bkm.children!=null) for (var i=0; i<bkm.children.length; i++) lowestLevelBookmarksAtTheRootLevel(bkm.children[i],nLevel+1);
}
lowestLevelBookmarksAtTheRootLevel(this.bookmarkRoot,0);
bookmarkRoot.remove();
for (var i=lowestLevelBookmarks.length-1; i>=0; i--) this.bookmarkRoot.createChild(lowestLevelBookmarks[i][0],"this.pageNum="+lowestLevelBookmarks[i][1]);
About spliting the file according to bookmarks, I assume the first page is where the bookmark refers. But the last page can be either the page where the next bookmark refers or the previous one... Let me know.
@+
... View more
‎Nov 06, 2023
03:37 AM
2 Upvotes
bonjour, Voici un exemple que j'avais proposé il y a quelques temps. Le script de cet exemple est :
for (var i=0; i<this.numFields; i++) {
var theName=this.getNthFieldName(i);
if (theName!="rotate") {
var f=this.getField(theName);
var rect=f.rect;
var length=rect[2]-rect[0];
var height=rect[1]-rect[3];
var centerX=(rect[0]+rect[2])/2;
var centerY=(rect[1]+rect[3])/2;
rect[0]=centerX-height/2;
rect[1]=centerY+length/2;
rect[2]=rect[0]+height;
rect[3]=rect[1]-length;
f.rect=rect;
var rot=f.rotation;
rot=rot+90;
if (rot>=360) rot=rot-360;
f.rotation=rot;
}
}
Tu peux partager un fichier si tu veux un script personnalisé.
@+
... View more
‎Nov 03, 2023
01:05 PM
Hi,
If you wish I tell you how it is possible to add an overwriting number when needed, please let me know the field name for "as found" in your example screenshot.
With your previous screenshot, I guess the "as left" field is "VAC 1"!
... and if possible, what is the calcutation for finding the "as found" field?
@+
... View more
‎Nov 03, 2023
06:04 AM
1 Upvote
...et en plus c'est gratuit !
@+
... View more
‎Nov 02, 2023
01:05 PM
Try that:
var v=Nombre(event.value) ;
var al=this.getField("VAC 1") ;
event.target.fillColor=color.transparent ;
al.fillColor=color.transparent ;
al.value="" ;
if (v) {
if (v<7.462 || v>7.538) event.target.fillColor=color.yellow ;
else {
event.target.fillColor=color.green ;
al.value=event.value ;
al.fillColor=color.vert ;
}
}
... but in a previous message, didn't you mention "... it will allow the user to type in the calibrated result so that the "as left" field turns green."?
Where do you place your script?
Where are fields "as found" and "as left"?
@+
... View more