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

JavaScript Crop/Shift

New Here ,
Mar 31, 2023 Mar 31, 2023

Copy link to clipboard

Copied

Hello Everyone, I am scanning books. After scanning, i need to crop  all the pages. I set up a series of buttons to move the crop box around after resetting the mediabox to [0,792,612,0]. 

I crop all the pages and when going through it's as if I never touched the pages. 

I restore the page using this: 

/* Restore Crop and Media Box to 8.5 x 11 */
this.setPageBoxes("Crop",this.pageNum,this.pageNum,[0,792,612 ,0]);
this.setPageBoxes("Media",this.pageNum,this.pageNum,[0,792,612 ,0]);

/* Crop from ALL sides */
var rCrop = this.getPageBox("Crop",this.pageNum); 
rCrop[0] += 9; // Adjust Left Side 
rCrop[1] -= 65; // Adjust Top Side 
rCrop[2] -= 90; // Adjust Right Side 
rCrop[3] -= 0; // Adjust Bottom Side 
this.setPageBoxes("Crop",this.pageNum,this.pageNum,rCrop);

/* Shift */
var rCrop = this.getPageBox("Crop",this.pageNum); 
rCrop[0] += 9; // Adjust Left Side 
rCrop[1] -= 45; // Adjust Top Side 
rCrop[2] += 9; // Adjust Right Side 
rCrop[3] -= 45; // Adjust Bottom Side 
this.setPageBoxes("Crop",this.pageNum,this.pageNum,rCrop);

and then move or crop via buttons using the same code as above to either crop or shift but with different numbers. 

Is there anything in there that I am missing that applies the changes to more than the page that is visible? 

 

Thanks.

Patrick Brewer

TOPICS
JavaScript , Scan documents and OCR

Views

469

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 ,
Apr 04, 2023 Apr 04, 2023

Copy link to clipboard

Copied

Hi,

the setPageBoxes command takes the pages you want to apply it too:

BarlaeDC_0-1680608459227.png

In the code you have specified above you pass in

- nStart = this.pageNum

- nEnd = this.pageNum

if you want to apply it to more pages you need to specify the start and end pages to be different

- nStart = 0 // the first page in the document

- nEnd = this.pageNum -1 ; // the last page ( starts from zero)

 

and use those when you are wanting to apply it.

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 ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

LATEST

is there a javascript to image shift a mutipage document up, down, left and right?

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