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

Split the batch into multiple pages according to the red frame

Participant ,
Oct 15, 2025 Oct 15, 2025


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.

 

ruihuang_0-1760576800488.png

 

TOPICS
JavaScript , PDF
269
Translate
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
3 ACCEPTED SOLUTIONS
Community Expert ,
Oct 16, 2025 Oct 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

 

 

 

 

View solution in original post

Translate
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 ,
Oct 16, 2025 Oct 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
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 ,
Oct 20, 2025 Oct 20, 2025
LATEST

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.

@+

View solution in original post

Translate
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 ,
Oct 16, 2025 Oct 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

 

 

 

 

Translate
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 ,
Oct 16, 2025 Oct 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 ,
Oct 20, 2025 Oct 20, 2025
LATEST

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.

@+

Translate
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