Skip to main content
Inspiring
October 16, 2025
Answered

Split the batch into multiple pages according to the red frame

  • October 16, 2025
  • 3 replies
  • 308 views


There are multiple red outer frames on a single PDF page. How to split it into multiple pages based on the size of these frames? I know this can be done using ExtendScript with Illustrator, but I want a simpler method that only uses scripts in Adobe Acrobat.

 

 

Correct answer bebarth

If it's possible for you to add marks to indicate the areas to be cropped, I think it's easier with square-type annotations.
In fact, the difficulty for you will come from the number of areas to indicate in the document, but if they're already drawn, that simplifies things a bit...
I've used this method in the past to crop different text areas in a document and extract them one by one.
This is an answer that certainly won't suit everyone, but it shows a possibility of using in JavaScript.
Here's a script that will do this:

var nbPages=this.numPages;
for (var p=0; p<nbPages; p++) {
	var zones=[];
	var annots=getAnnots({nPage:p});
	if (annots!=null) {
		for (var i=0; i<annots.length; i++) {
			if (annots[i].type=="Square") {
				zones.push(annots[i].rect);
			}
		}
		for (var i=0; i<zones.length-1; i++) {
			this.insertPages({
				nPage: p,
				cPath: this.path,
				nStart: p
			})
		}
		for (var i=0; i<zones.length; i++) {
			this.setPageBoxes({
				cBox: "Crop",
				nStart: p+i,
				rBox: zones[i]
			})
		}
	}
	p+=zones.length;
	nbPages+=zones.length;
}
var annots=getAnnots();
for (var i=0; i<annots.length; i++) {
	if (annots[i].type=="Square") annots[i].destroy();
}
this.saveAs(this.path.replace(/.pdf$/i,"_Cropped.pdf"));

Below, you will find your example on several pages before and after cropping.

@+

3 replies

bebarth
Community Expert
bebarthCommunity ExpertCorrect answer
Community Expert
October 20, 2025

If it's possible for you to add marks to indicate the areas to be cropped, I think it's easier with square-type annotations.
In fact, the difficulty for you will come from the number of areas to indicate in the document, but if they're already drawn, that simplifies things a bit...
I've used this method in the past to crop different text areas in a document and extract them one by one.
This is an answer that certainly won't suit everyone, but it shows a possibility of using in JavaScript.
Here's a script that will do this:

var nbPages=this.numPages;
for (var p=0; p<nbPages; p++) {
	var zones=[];
	var annots=getAnnots({nPage:p});
	if (annots!=null) {
		for (var i=0; i<annots.length; i++) {
			if (annots[i].type=="Square") {
				zones.push(annots[i].rect);
			}
		}
		for (var i=0; i<zones.length-1; i++) {
			this.insertPages({
				nPage: p,
				cPath: this.path,
				nStart: p
			})
		}
		for (var i=0; i<zones.length; i++) {
			this.setPageBoxes({
				cBox: "Crop",
				nStart: p+i,
				rBox: zones[i]
			})
		}
	}
	p+=zones.length;
	nbPages+=zones.length;
}
var annots=getAnnots();
for (var i=0; i<annots.length; i++) {
	if (annots[i].type=="Square") annots[i].destroy();
}
this.saveAs(this.path.replace(/.pdf$/i,"_Cropped.pdf"));

Below, you will find your example on several pages before and after cropping.

@+

Thom Parker
Community Expert
Community Expert
October 16, 2025

Those rectangles are part of the page content. A script cannot get any information on page graphics.  If the rectangles are a consistent known size, then a script could be written to split the page. But if not, then unless you follow the advice from PDF_AS and add fields or some other type of annotation to mark the location, a scripted solutions is not possible.  This could be done with a plug-in, but it would be tricky and expensive. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
PDF Automation Station
Community Expert
Community Expert
October 16, 2025

1) Create a form field for each rectangle to get the rect property of each area by running the following script in the console:

this.getField("Text1").rect;

2)  Run a script to crop the page.

3)  Run a script to save the file.

4)  Reverse crop the page and repeat for the next area:

https://pdfautomationstation.substack.com/p/cropping-and-reverse-cropping-pdf