
you can use a handy parameter in the function:
app.activeDocument.pages.add(LocationOptions.AT_END);
You don't need the second parameter "reference", because AT_END already tells ID precisely where the new page must come (i.e., if you want to always add a page after the first one, you'd use AFTER for at and app.activeDocument.pages[0] for reference).
That, however, only adds a page. To make your text flow onto it, you need to manually add a new text frame and "thread" (link) the one from the previous page:
newframe = newpage.textFrames.add(..)
startframe.nextTextFrame = newframe; // <- thread

Unfortunately, only adding a new text frame to a page does not automatically size it to its parent page's margins. All you get is a tiny new frame in the top left. So you have to read out the page size (using its property) and the current margins, and then you can resize the frame. Another snag awaits you, if your margins are mirrored: for some reason, the MarginPreferences object does not "see" whether you are on a left or a right hand sided page. So I use page.index to check if it's odd, and if so, reverse left and right margins.
Another possible pitfall is when your text contains Continuously Overset items -- text that will not fit on a page, whatever you do. That may happen with a large table, a large image, or text with some weird attribute such as a huge left indent or No-Break applied to more text than can fit on a single line. If not checked, this script would keep on checking for overflow, detect it, create a new page and text frame, which then will also overflow and so on and so forth. A quick check is to add a new text frame and check if it actually contains anything -- a Continuously Overflowing frame will always be entirely empty.
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-51718-1.html
美国需要慢慢习惯
等中国有这能力了
物价高是因为中国国内税率过高跟央行印钞量过大的结果