Skip to main content
Known Participant
September 8, 2023
Answered

turn N -up pages per sheet to 1Page per sheet

  • September 8, 2023
  • 2 replies
  • 44777 views

I have pdf file consists of 31 pages , each page contain 8 images , each of them size is 8.6 * 5.5 cm 

Is there a script or automatic method to save each image as a single pdf page with its size ( 8.6 * 5.5 cm ) ?

Note : Images that I want to save each as single pdf page is marked by red rectangle in the example image attached here

Thanks

 

This topic has been closed for replies.
Correct answer bebarth

No problem , take your time , I'll wait you 

Is these 4 lines I test them alone ? or put them in the first script you attached ? or How ?

when I tested them alone this message apears : ReferenceError: theFile is not defined
1:Console:Exec
undefined


In fact that was not too long.

Forget my "86x55_BB.pdf" file and only open your "Test.pdf" file, then run this script from the console window.

//
var largeur=86;
var hauteur=55;
var offsetH=-16.5;
var deltaH=91;
var offsetV=31;
var deltaV=60;
//
var mm2pt=72/25.4;
var nbPages=this.numPages;
for (var p=0; p<nbPages; p++) {
	for (v=0; v<4; v++) {
		for (h=0; h<2; h++) {
			this.newPage({
				nWidth: largeur*mm2pt,
				nHeight: hauteur*mm2pt
			});
			this.addWatermarkFromFile({
				cDIPath: this.path,
				nSourcePage: p,
				nStart: this.numPages-1,
				nHorizAlign: app.constants.align.left,
				nVertAlign: app.constants.align.top,
				nHorizValue: (offsetH-h*deltaH)*mm2pt,
				nVertValue: (offsetV+v*deltaV)*mm2pt
			});			
		}
	}
}
this.deletePages(0,nbPages-1);
this.saveAs(this.path.replace(/.pdf$/i," \(One Image Per Page\).pdf"));

 Is that working fine? Let me know.

@+ 

2 replies

Thom Parker
Community Expert
Community Expert
September 9, 2023

You don't need a script. A tool for extracting images is already built into Acrobat.

Go to the Tools list and select "Export PDF"

Then set these options:

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
September 9, 2023

Thanks for your reply Tom

But when I do these steps , it exports only background image without any variables ( Name , class )

Known Participant
September 15, 2023

Hi

Excuse me @bebarth : What is the best and simplest method to measure distances in pdf file ?

Known Participant
September 8, 2023

Any help Here

bebarth
Community Expert
Community Expert
September 8, 2023

Hi,

Place the attached file in the same folder as your file then open it and run this script from the console window:

 

//
var offsetH=-16.5;
var deltaH=91;
var offsetV=31;
var deltaV=60;
//
var aRect=this.getPageBox();
var thePath=this.path;
var directory=thePath.substring(0,thePath.length-this.documentFileName.length);
var theFile=directory+"Test.pdf";
var mm2pt=72/25.4;
var otherDoc=app.openDoc(theFile);
var nbPages=otherDoc.numPages;
otherDoc.closeDoc();
for (var p=0; p<nbPages; p++) {
	for (v=0; v<4; v++) {
		for (h=0; h<2; h++) {
			this.newPage({
				nWidth: aRect[2],
				nHeight: aRect[1]
			});
			this.addWatermarkFromFile({
				cDIPath: theFile,
				nSourcePage: p,
				nStart: this.numPages-1,
				nHorizAlign: app.constants.align.left,
				nVertAlign: app.constants.align.top,
				nHorizValue: (offsetH-h*deltaH)*mm2pt,
				nVertValue: (offsetV+v*deltaV)*mm2pt
			});			
		}
	}
}
this.deletePages(0);
this.saveAs(this.path.replace(/.pdf$/i," \(One Image Per Page\).pdf"));

 

@+

Known Participant
September 9, 2023

Hi,

  1. The 86x55_BB.pdf file must be in the same folder as your Test.pdf file.
  2. Open the 86x55_BB.pdf file.
  3. Paste the script in the console window.
  4. Select all the script (with ctrl A).
  5. Press the ENTER key of the numerical panel (not the Return key of the alphabetical panel).
  6. The script must run then you will get a new file with one image per page.

Please note that the script can't check if there is effectively an image on each page and extract 8 images per page.

So, as on your last page you only have one image, it will extract 7 blank pages at the end of the new file...

@+


Thanks For Your reply

I made the steps exactly but when i pressed ( Enter ) 

Undefined is wrote under the script and a new empty file created with name  : 86x55_BB (One Image Per Page) consist of one empty page ( same as file that you attached )