Hi,
to see if anyone can help me.
• I need to define a script, to create multiple pages.
at the moment:
• it is believed only one:
the code is this:
var myDoc = app.activeDocument;
var myPg = myDoc.pages.item(-1);
var myLastPage = myDoc.pages.add.(LocationOptions.AT_END, myPg);
thanks to all !
Hi Raul,
Your script is working fine, the error is pages.add.
Raul_rubi wrote:
Hi,
to see if anyone can help me.
• I need to define a script, to create multiple pages.
at the moment:
• it is believed only one:
the code is this:
var myDoc = app.activeDocument;
var myPg = myDoc.pages.item(-1);
var myLastPage = myDoc.pages.add.(LocationOptions.AT_END, myPg);
thanks to all !
var myDoc = app.activeDocument;
var myPg = myDoc.pages.item(-1);
var myLastPage = myDoc.pages.add(LocationOptions.AT_END, myPg);
thx
csm_phil
Hi Rubi,
The problem is you using the period character after the add text before. so this is the problem.
For your information if the anwswer is right please check the right answer otherwise lot of people go and read your thread that is waste of time. please do the process yes or no.
thx
csm_phil
Is your problem that thhe script only adds a single page? That's easily fixed.
By the way, if you use AT_END you don't need to supply an additional pointer, the new page will always end up there.
Untested but this ought to work:
var myDoc = app.activeDocument;
var addPages = 6;
// Save first added page ...
var myFirstAddedPage = myDoc.pages.add(LocationOptions.AT_END);
addedPages--;
while (addPages > 0)
{
addPages--;
myDoc.pages.add(LocationOptions.AT_END);
}
.. 'myFirstAddedPage' will point to the first one of your newly added pages.
> The problem is you using the period character after the add text before. so this is the problem.
Hah -- I saw that in my code and thought, "huh why did I do *that*!?" (I copied a part of the original.)
Raul, it would have helped if you told us *why* your code failed! The error message would have indicated this mistake right away.
ok ,
I understand that he had got it wrong ( var myLastPage = myDoc.pages.add.(LocationOptions.AT_END, myPg);
but even with what you have written:
[Jongware] wrote:
Is your problem that thhe script only adds a single page? That's easily fixed.
By the way, if you use AT_END you don't need to supply an additional pointer, the new page will always end up there.
Untested but this ought to work:
var myDoc = app.activeDocument;
var addPages = 6;
// Save first added page ...
var myFirstAddedPage = myDoc.pages.add(LocationOptions.AT_END);
addedPages--;
while (addPages > 0)
{
addPages--;
myDoc.pages.add(LocationOptions.AT_END);
}
.. 'myFirstAddedPage' will point to the first one of your newly added pages.
I can not create multiple pages
in my case I have now created 3 pages
and after the 3 would create 2 more for example.
Thanks
Raul_rubi wrote:
I can not create multiple pages
Please tell us why not! Help us to help you!
But, I'm back behind my computer so let's see what's wrong. Running my script now -- oops.
-----------------------------
JavaScript Error!
Error Number: 2
Error String: addedPages is undefined
File: ...
Line: 5
Source: addedPages--;
-----------------------------
Well, that's pretty clear. I mis-typed 'addedPages' on that line, it should have been 'addPages'. With that corrected, the script does indeed add 6 empty pages at the end of my current document.
Sorry Jongware,
I do not understand.
and may close the issue but would not be well.
but would not help anyone because the issue is not solved.
but what I really want is code Script
to create several pages after a specific.
for example after page 2.
eg add 6 pages
See if you can write it, and it is operational.
Thanks,
That's different from what I understood from your original post, but ... still no problem. Instead of AT_END, which does what it says, use AFTER (this *also* does what it says):
var myDoc = app.activeDocument;
var addPages = 6;
// Page number 2 is item(1), since page number 1 is item(0):
var addAfter = app.activeDocument.pages.item(1);
// Save first added page ...
var myFirstAddedPage = myDoc.pages.add(LocationOptions.AFTER, addAfter);
addPages--;
// .. then add the others AFTER it as well
while (addPages > 0)
{
addPages--;
myDoc.pages.add(LocationOptions.AFTER, myFirstAddedPage);
}
You type too quickly jong although I did do it slightly different…
app.activate();
var myDoc = app.activeDocument;
var midPage = myDoc.pages.middleItem(); // some middle ref
var addPages = 6;
do {
myDoc.pages.add( LocationOptions.AFTER, midPage );
addPages--;
} while ( addPages > 0 )
Just edited that app.activate which was clearly wrong… needed ()
North America
Europe, Middle East and Africa
Asia Pacific