PNG Page Range
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / PNG Page Range
- This topic has 2 replies, 2 voices, and was last updated 10 years, 1 month ago by Stuart Horner.
-
AuthorPosts
-
-
March 12, 2014 at 11:17 am #67617Stuart HornerMember
Hi, could anyone please give me an example of how to specify a PNG page range in JavaScript. I have no problem with PDF page ranges and have used Jongware’s guide as reference but whatever I try results in all pages being exported. A working example would be much appreciated.
-
March 14, 2014 at 2:57 pm #67659Theunis De JongMember
It seems PNG exporting is some kind of left-over or not-(yet?)-fully implemented. The other export formats *do* have various options, but PNG does not. It can’t be coincidental that “PNG” is also missing from the list of exportable formats (at least, it is in my CS4).
Here is a small function I wrote a while ago that implements a PNG export. Since you cannot export an entire *page*, you have to target a *group* instead. So first thing the script does is over-riding all master page items on each page, so they can be included; then it adds all items on the page to a new group, and finally exports *that*.
So it changes your document — Save before running and Do Not “Save” it afterwards!
This script exports all pages in your document but can easily be rewritten to export a certain page range only.
for (pg=0; pg<app.activeDocument.pages.length; pg++)
{
page = app.activeDocument.pages[pg];
for (mas=0; mas < page.appliedMaster.pageItems.length; mas++)
try {
page.appliedMaster.pageItems[mas].override(app.activeDocument.pages[pg]);
} catch (a_bah) { }g = page.groups.add(page.pageItems);
g.exportFile(ExportFormat.PNG_FORMAT, File(Folder.myDocuments.fsName+”/”+(page.name)+”.png”));
} -
March 15, 2014 at 2:38 am #67660Stuart HornerMember
Hi Jongware, thanks for this, I wasn’t aware that PNG targeted groups rather than pages but since you can export a selection, that would make sense.
-
-
AuthorPosts
- You must be logged in to reply to this topic.