• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Insert blank page automatically

New Here ,
Jan 13, 2023 Jan 13, 2023

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.

TOPICS
Edit and convert PDFs , JavaScript , Print and prepress

Views

2.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 14, 2023 Jan 14, 2023

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
...

Votes

Translate

Translate
Community Expert ,
Jan 14, 2023 Jan 14, 2023

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?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2023 Jan 14, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2023 Jan 14, 2023

Copy link to clipboard

Copied

Try my script, that should work!

...and let me know.

@+

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2023 Jan 14, 2023

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:

Capture d’écran 2023-01-14 à 19.39.14.png

@+

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2023 Jan 14, 2023

Copy link to clipboard

Copied

ReferenceError: txt is not defined
1:Console:Exec
undefined

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2023 Jan 14, 2023

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?

@+

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2023 Jan 14, 2023

Copy link to clipboard

Copied

Thank you, the code works, i made a mistake when i entered the code into the console.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

Please help me

How could I insert an empty page automatically after Page 1/1 and Page 3/3 ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2023 Nov 30, 2023

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]);
}

 @+

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 30, 2023 Nov 30, 2023

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.

page 1in1.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2023 Dec 01, 2023

Copy link to clipboard

Copied

Hi,
Maybe I didn't understand your request, but for me that works fine...

Capture_d’écran_2023-12-01_à_12_52_41.pngCapture_d’écran_2023-12-01_à_12_53_23.png

@+

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2023 Dec 01, 2023

Copy link to clipboard

Copied

The script will not work on documents with only one page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2023 Dec 01, 2023

Copy link to clipboard

Copied

LATEST

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 😉

@+

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines