Copy link to clipboard
Copied
Hi
I have several documents in one document, there are 3923 pages, some documents have one page each and some have 3 pages.
How could i insert an empty page automatically after pag. 1 of 1 and pag. 3 of 3.
I want to print the documents 2 sides.
Hi,
Try the action wizard included in the attached file or directly this script from the console:
d0=new Date();
starting=util.printd("mm/dd/yy – hh:MM:ss tt",d0);
var addBlankPageAfter=[];
for (var p=0; p<this.numPages-1; p++) {
console.clear();
console.println("Process starting: "+starting);
console.println("Processing the page #"+(p+1)+"/"+this.numPages);
var numWords=this.getPageNumWords(p);
for (var i=0; i<numWords; i++) {
var ckWord=this.getPageNthWord(p, i, true);
if (this.getPag
...
Copy link to clipboard
Copied
This can be done with a script, if there's a way to identify where each document ends. Are there bookmarks pointing to the start of each document, for example?
Copy link to clipboard
Copied
All documents start on the right page with:
Annex No. 1
content
ending with:
__________________________________________________________________________
Printing Date: 03.01.2023 - 16:01 pag. 1 of 1
ex. 2
Annex No. 1
content
ending with:
__________________________________________________________________________
Printing Date: 03.01.2023 - 16:02 pag. 3 of 3
Copy link to clipboard
Copied
Try my script, that should work!
...and let me know.
@+
Copy link to clipboard
Copied
Hi,
Try the action wizard included in the attached file or directly this script from the console:
d0=new Date();
starting=util.printd("mm/dd/yy – hh:MM:ss tt",d0);
var addBlankPageAfter=[];
for (var p=0; p<this.numPages-1; p++) {
console.clear();
console.println("Process starting: "+starting);
console.println("Processing the page #"+(p+1)+"/"+this.numPages);
var numWords=this.getPageNumWords(p);
for (var i=0; i<numWords; i++) {
var ckWord=this.getPageNthWord(p, i, true);
if (this.getPageNthWord(p, i, false)=="pag. " && ((this.getPageNthWord(p, i+1, true)=="1" && this.getPageNthWord(p, i+2, true)=="of" && this.getPageNthWord(p, i+3, true)=="1") || (this.getPageNthWord(p, i+1, true)=="3" && this.getPageNthWord(p, i+2, true)=="of" && this.getPageNthWord(p, i+3, true)=="3"))) {
addBlankPageAfter.push(p);
break;
}
}
}
var pageBox=this.getPageBox("Crop",0);
if (addBlankPageAfter.length) {
for (var i=addBlankPageAfter.length-1; i>=0; i--) {
console.clear();
console.println("Process starting: "+starting);
console.println("Adding a blank page after page #"+(addBlankPageAfter[i]+1));
this.newPage(addBlankPageAfter[i]+1, pageBox[2], pageBox[1]);
}
this.saveAs(this.path.replace(/.pdf$/i," & Blank Pages.pdf"));
this.pageNum=0;
this.viewState={overViewMode:2};
var plurial=(addBlankPageAfter.length>1)?"s":"";
var txt=addBlankPageAfter.length+" blank page"+plurial+" added.\r\r";
} else var txt="No page found in this document.\r\r";
df=new Date();
ending=util.printd("mm/dd/yy – hh:MM:ss tt",df);
console.println("\rProcess ending: "+ending);
temps=(df.valueOf()-d0.valueOf())/1000/60;
var theMinutes=parseInt(temps);
var theSeconds=(temps-theMinutes)*60;
var theSeconds=parseInt(theSeconds*10)/10;
var theTime="";
if (theMinutes>0) {
if (theMinutes==1) var theTime="1 minute";
else var theTime=theMinutes+" minutes";
}
if (theSeconds>0) {
if (theSeconds<2) var theTime=theTime+" "+theSeconds+" second";
else var theTime=theTime+" "+theSeconds+" seconds";
}
var theTime=theTime.replace(/^\s+|\s+$/gm,"");
txt+="Process starting: "+starting+"\rProcess ending: "+ending+"\rProcess duration: "+theTime;
console.clear(); console.show();
console.println(txt);
app.alert(txt,3);
Here is the result of a test I did:
@+
Copy link to clipboard
Copied
ReferenceError: txt is not defined
1:Console:Exec
undefined
Copy link to clipboard
Copied
Strange!
You execute the script from the console and the error comes from line #1 whereas the txt variable shoud come at the end of the script!
Did you copy/paste the entire code in the console then select all and ENTER key of the numerical panel?
@+
Copy link to clipboard
Copied
Thank you, the code works, i made a mistake when i entered the code into the console.
Copy link to clipboard
Copied
Please help me
How could I insert an empty page automatically after Page 1/1 and Page 3/3 ?
Copy link to clipboard
Copied
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]);
}
@+
Copy link to clipboard
Copied
Hi @bebarth ,
Thank you for your help. But the script doesn't run as I expected. You can see the image below.
Copy link to clipboard
Copied
Hi,
Maybe I didn't understand your request, but for me that works fine...
@+
Copy link to clipboard
Copied
The script will not work on documents with only one page.
Copy link to clipboard
Copied
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 😉
@+