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

Resizing a page from the bottom edge

Engaged ,
Oct 14, 2009 Oct 14, 2009

Copy link to clipboard

Copied

I have a document where my client has requested that the pages be shortened by 30mm in height. The width of the page stays the same. If I enter a new page size for the document, Indesign adjusts it from the centre of the page, but is there a way to get it to adjust it from the bottom edge? In other words to effectively get the top 30mm trimmed off the page.

None of my artwork encroaches into the top 30mm, but it does get close to the bottom edge. If I could shave the top off the page like this then I wouldn't have to move anything, but with the default behaviour I will have to adjust every page. Is this sort of thing possible?

Thanks

TOPICS
Scripting

Views

3.5K

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

LEGEND , Oct 15, 2009 Oct 15, 2009

The truth of the matter is that the script was unnessesarily complicated. Marc had the right idea. This should get master page items as well (although it's totally untested):

var myDoc = app.activeDocument;
myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
myDoc.documentPreferences.pageHeight -= 30;     //*** Make DOC 30mm shorter

   myPIs = myDoc.pageItems.everyItem();
   myPIs.locked = false;
   myPIs.move(undefined, [0,-15]);

Harbs

Votes

Translate

Translate
Guide ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

Once the page is resized, why don't you offset the objects by 15 mm vertically?

var p, pItems = app.activeDocument.pageItems.everyItem().getElements();
while(p=pItems.pop()) p.move(undefined,[0,'15 mm']);

Edit: using allPageItems was not correct.

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
Guest
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

Someone else replied more quickly. But they did not address masterPage elements as well as locked pageItems.

Yes you can using a script. After resizing the document, you will have to step through each page, select ALL, and move them but 15mm UP.

============================

var myDoc = app.activeDocument;

myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;

myDoc.documentPreferences.pageHeight -= 30;     //*** Make DOC 30mm shorter

for (cpt = 0; myDoc.pageItems.length; cpt++)     //*** UNLOCK all pageItems

  myDoc.pageItems[cpt].locked = false;

var myPGS = mydoc.pages;

for (cptPG = 0; cptPG < myPGS.length; cptPG++)

{

  app.select(NothingEnum.nothing);    //*** IMPORTANT in CS2 anyway. Can't remember why***

  myDoc.layoutWindows[0].activePage = myPGS[cptPG];    //*** IMPORTANT

  OverrideMasterPageItems (myPGS[cptPG]);     //*** IMPORTANT

  app.select(SelectAll.all);

  var myITM = myDoc.groups.add(app.selection);
  myITM.move(undefined, [0,-15]);
  myITM.ungroup();

}

===================

This is a modified script I use every day to optimize page height for film output. It keeps element centered to where they were.

I added UNLOCK in case you did have elements locked!!!

I did NOT test 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
LEGEND ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

You're much better off avoiding select().

I'd do something like this:

var myDoc = app.activeDocument;
myDoc.viewPreferences.verticalMeasurementUnits =  
MeasurementUnits.millimeters;
myDoc.documentPreferences.pageHeight -= 30;     //*** Make DOC 30mm  
shorter

var myPGS = mydoc.pages;
for (cptPG = 0; cptPG < myPGS.length; cptPG++)
{
   myPIs = myPGS[cptPG].pageItems.everyItem();
   myPIs.locked = false;
   myPIs.move(undefined, [0,-15]);
}

Harbs

http://www.in-tools.com

Innovations in Automation

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
Guest
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

Cool Harbs. THis is an old script. And Yes I prefer not using select nowadays.

Also you skip the grouping. I was wondering why I am doing it?

Thx, Alex.

PS. How do you do the code insert wihtin a window?

2nd could you check this thread I've posted?

http://forums.adobe.com/thread/507105?tstart=0

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
LEGEND ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

CTC Imaging wrote:

PS. How do you do the code insert wihtin a window?

In the web interface, use the double right arrows to select syntax highlighting.

Using email I use [ code ] and [ / code ] although you can specify sytax highlighting as well...

The big problem with posting code by email, is that it gets mangled very easily...

Harbs

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
Engaged ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

Thanks guys - it seems like this is feasible then.

Harbs - I get an error on line 6 - 'mydoc is undefined'. Is this something I could have done when pasting in the script or do I need to change something?

Thanks

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
LEGEND ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

JS is caps sensitive.

It needs to be myDoc instead of mydoc.

(It was a typo on my end...)

Harbs

http://www.in-tools.com

Innovations in Automation

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
Engaged ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

Thanks Harbs, that did the trick!

Can I please just ask for one more thing - is it possible to get it to adjust master page items as well. All my page numbers got left behind off the bottom of the page

Thanks

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
Guest
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

This line should make them available ==> OverrideMasterPageItems (myDocBuilt.pages[0]);     //*** IMPORTANT"

Now if they end up OUTSIDE the page at the bottom, then you need to access the spreads instead of the pages when moving them!

NOW, I figured that's why I was using ==> app.select(SelectAll.all);

But it works with spreads and it's cleaner.

Alex.

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
LEGEND ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

The truth of the matter is that the script was unnessesarily complicated. Marc had the right idea. This should get master page items as well (although it's totally untested):

var myDoc = app.activeDocument;
myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
myDoc.documentPreferences.pageHeight -= 30;     //*** Make DOC 30mm shorter

   myPIs = myDoc.pageItems.everyItem();
   myPIs.locked = false;
   myPIs.move(undefined, [0,-15]);

Harbs

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
Engaged ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

That works beautifully - thanks Harbs!

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
Engaged ,
Oct 15, 2009 Oct 15, 2009

Copy link to clipboard

Copied

Sorry, I spoke too soon.

I just tried it on another similar file and got Error Number:11265 on Line 7.

'This value would cause one or more objects to leave the pasteboard'

I'm not sure what is different about the two files that one would work but not the other?

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
LEGEND ,
Oct 16, 2009 Oct 16, 2009

Copy link to clipboard

Copied

Maybe you have an object right near the top of a pasteboard.

replace:

myPIs.move(undefined, [0,-15]);

with:

myPIs = myPIs.getElements();
for(var j=0;j<myPIs.length;j++){
	try{myPIs<j>.move(undefined, [0,-15]);
}

Harbs

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
Enthusiast ,
Oct 16, 2009 Oct 16, 2009

Copy link to clipboard

Copied

Hi,

can anybody explain the difference between these two lines to me?

------

var p, pItems = app.activeDocument.allPageItems;
while(p=pItems.pop())
p.move(undefined,[0,'15 mm']);

------

-----

var p, pItems = app.activeDocument.pageItems.everyItem().getElements();
while(p=pItems.pop()) p.move(undefined,[0,'15 mm']);

-----

Why ist the first line wrong, cause it works for me?

How can I type code as code in the forum?

rübi

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
LEGEND ,
Oct 16, 2009 Oct 16, 2009

Copy link to clipboard

Copied

The first one will move nested items (like groups for example) twice.

Harbs

http://www.in-tools.com

Innovations in Automation

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
Enthusiast ,
Oct 16, 2009 Oct 16, 2009

Copy link to clipboard

Copied

ah, thanks. I had no grouped objects in my testfile before. Now it seems to be clear.

rübi

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
Engaged ,
Oct 18, 2009 Oct 18, 2009

Copy link to clipboard

Copied

Hi Harbs

I replaced that line with your new content as suggested, but I now get and Error 15 on Line 10 - 'Try without catch or finally'.

Any ideas?

Steve

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
LEGEND ,
Oct 18, 2009 Oct 18, 2009

Copy link to clipboard

Copied

It looks like part of the code got lost somehow...

This is what it should have been:

 try{myPIs.move(undefined, [0,-15]);}catch(e){}

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
Engaged ,
Oct 18, 2009 Oct 18, 2009

Copy link to clipboard

Copied

LATEST

Thanks Harbs - that works beautifully.

Thanks very much for taking the time to work that out for me.

It's actually also quite cool to watch it do its thing

Steve

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