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

Exporting Page Elements as Full-Page PNGs? is this possible?

Guest
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Hi Everybody,

 

I have a 12-page document tht needs animating in Animate. So I need to export all photos, arrows, headers, textboxes, etc. as full-page PNGs, NOT cropped element PNGs, and NOT full-page flat PNGs. Like every single element isolated as a document-size PNG.  

 

Is this possible at all, if so that would save me a LOT of hassle.

 

Thanks so much for any suggestions!

 

 

TOPICS
EPUB , How to , Import and export , Scripting

Views

239

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

Advisor , Jan 18, 2021 Jan 18, 2021

Hello,

The script in the link below does what you are looking for.

https://gist.github.com/anonymous/7677d654c1357ee6d3ae1a1dc246c3b6

// Set resolution options
  var rp = [72,150,300];

// Set EXPORT presets
    app.pngExportPreferences.exportResolution = 72;
    app.pngExportPreferences.antiAlias = true;
    app.pngExportPreferences.pngQuality = PNGQualityEnum.MAXIMUM;
    app.pngExportPreferences.pngColorSpace = PNGColorSpaceEnum.RGB;
    app.pngExportPreferences.pngExportRange = PNGExportRangeEn
...

Votes

Translate

Translate
Advisor ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

LATEST

Hello,

The script in the link below does what you are looking for.

https://gist.github.com/anonymous/7677d654c1357ee6d3ae1a1dc246c3b6

// Set resolution options
  var rp = [72,150,300];

// Set EXPORT presets
    app.pngExportPreferences.exportResolution = 72;
    app.pngExportPreferences.antiAlias = true;
    app.pngExportPreferences.pngQuality = PNGQualityEnum.MAXIMUM;
    app.pngExportPreferences.pngColorSpace = PNGColorSpaceEnum.RGB;
    app.pngExportPreferences.pngExportRange = PNGExportRangeEnum.EXPORT_RANGE;

// Resolution Select Dialog
  var w;    
  w = new Window('dialog', 'Export Presets');  
  w.orientation = 'row';
  with (w) 
    {
	   w.sText = add('statictext', undefined, 'Select Export Resolution:');
	   w.dropdown = add ( 'DropDownList',undefined,undefined,{items:rp});
	   w.btnOK = add('button', undefined, 'OK');
    };
  w.dropdown.selection=0; 
  w.show();  
  
  // Set resolution
	  var x = 0;
	  x = x + w.dropdown.selection;
    app.pngExportPreferences.exportResolution = rp[x];

// SElECT Folder locations
  var myFileAmount = 0; 
  var myFileLocation = Folder.selectDialog("Please select path of InDesign Files");
  myFolder = new Folder ([myFileLocation]);
  myFolderContents = myFolder.getFiles("*.indd"); // array
  myFileAmount = (myFolderContents.length - 1); 

  // CHECK IF FILES IN FOLDER
    if (myFileAmount < 0){alert("No Files in selected folder");}
    else
      {
        var mySaveLocation = Folder.selectDialog("Please select path to Save PNG");
        mySaveFolder = new Folder ([mySaveLocation]);

      // OPEN FILES One at a time
      for (i = myFileAmount; i >= 0; i--)
        { 
          app.open(File (myFolderContents[i]));
          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
          
          // SET Active Document
          var myDoc = app.activeDocument;

		      // EXPORT

          //One Page at a time
          for (var p=0; p < myDoc.pages.length; p++)
            {//page loop
             var pname = myDoc.pages.item(p).name; 
      
             //set all items in file hiden
             for (var itemnum=0;itemnum < myDoc.pages.item(p).pageItems.length; itemnum++)
              {
                myDoc.pages.item(p).pageItems.item(itemnum).visible = false;
              }

             // set page to export
             app.pngExportPreferences.pageString = pname;
      
             //add a 0 in from on less than 10
             if (p<9){var pnm=0;}else{var pnm=""}
      
              //LOOP Through items Set Visibility, export a PNG, Set Visibility
             for (var itemexport=0;itemexport < myDoc.pages.item(p).pageItems.length; itemexport++)
               {
                var itm = itemexport+1;//items start at 1 not 0
                myDoc.pages.item(p).pageItems.item(itemexport).visible = true;
                //ACTUALLY EXPORTING
                app.activeDocument.exportFile(
                 ExportFormat.PNG_FORMAT, 
                File(mySaveFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0]  + "_"+ pnm + pname + "_" + itm +".png"),
                false, 
                   );
                //SET VISIBILITY
                myDoc.pages.item(p).pageItems.item(itemexport).visible = false;
        }  
      }
      
       app.activeDocument.close(SaveOptions.no);
    }
}	

 

Regards,

Mike

 

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