I am using the script inbuilt in photoshop, but if some of my layers work are outside canvas, it trims those to the visible area only.

But we need everything in the layer in png, whether is was visible in canvas or it is outside.

Best, Gunjan

  • Hi Gunjan, welcome to GDSE and thanks for your question. If you want to know more about the site, please see the help center or ping one of us in the Graphic Design Chat once your reputation is sufficient (20). Keep contributing and enjoy the site! Did you Google this question, and if so, why weren't the results satisfactory?
    – PieBie
    Commented Dec 8, 2015 at 7:57

1 Answer 1


I have got the answer from Adobe.

You can append appDocument.revealAll().

Also you can take the snapshot of the same before revealing all and then restore the snapshot. Below is the function you can copy in exporting all layers to file. Then call the takeSnapshot(); first then appDocument.revealAll(); in the start of the main.

and in the end call restoreSnapshot(); to bring it to the same position

function takeSnapshot () { 
   var desc = new ActionDescriptor();
   var sref = new ActionReference();
   desc.putReference(charIDToTypeID("null"), sref); 
   var fref = new ActionReference(); 
   fref.putProperty(charIDToTypeID("HstS"), charIDToTypeID("CrnH")); 
   desc.putReference(charIDToTypeID("From"), fref ); 
   executeAction(charIDToTypeID("Mk  "), desc, DialogModes.NO ); 

function restoreSnapshot(){
var doc = app.activeDocument;
var hs = doc.historyStates;
for(var a =hs.length-1;a>=0;--a){
   if(hs[a].snapshot) {
       doc.activeHistoryState = hs[a];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.