PNG Page Range

This topic contains 2 replies, has 2 voices, and was last updated by  stuarth64 1 year, 2 months ago.

  • Author
  • #67617


    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.

  • #67659


    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 {
    } catch (a_bah) { }

    g = page.groups.add(page.pageItems);
    g.exportFile(ExportFormat.PNG_FORMAT, File(Folder.myDocuments.fsName+”/”+(”.png”));

  • #67660


    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.

You must be logged in to reply to this topic.