Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-08-2009, 03:51 PM   #1
booder101
Registered User
 
Join Date: Oct 2009
Posts: 2
Default Export png24 from Illustrator with white background

Hello, I think this there is a simple solution, I just cannot find it. I want to export a layer of Illustrator with a white background. I am able to export the layer, but it has a transparent background. I got the basic code off the internet and just changed options.transparency = false but this does not do the trick. Greatly appreciate any help - I have looked thru Javascript/actionscript reference guides searching for setting background to white but have not had luck.. Thank you!
=-======================

script follows:
/**
* @author Niels Bosma ([email protected]
*/

var folder = Folder.selectDialog();
var document = app.activeDocument;
if(document && folder)
{
var options = new ExportOptionsPNG24();
options.antiAliasing = true;
options.transparency = false;

var n = document.layers.length;
for(var i=0; i<n; ++i)
{
hideAllLayers();
var layer = document.layers[i];
layer.visible = true;

var file = new File(folder.fsName+"/"+layer.name+".png");

var options = new ExportOptionsPNG24();
options.artBoardClipping = true;

document.exportFile(file,ExportType.PNG24,options) ;


}

showAllLayers();
}

function hideAllLayers()
{
forEach(document.layers, function(layer) {
layer.visible = false;
});
}

function showAllLayers()
{
forEach(document.layers, function(layer) {
layer.visible = true;
});
}

function forEach(collection, fn)
{
var n = collection.length;
for(var i=0; i<n; ++i)
{
fn(collection[i]);
}
}
booder101 is offline   Reply With Quote
Old 10-10-2009, 12:34 AM   #2
elytexeira
Member
 
Join Date: Jul 2009
Posts: 89
Default

PNG supports transparency. So one solution could be changing the setup in your illustrator file. There you could change the background to white instead of transparent.


---------------------
currently working at : http://www.probooks.com.mx
elytexeira is offline   Reply With Quote
Old 10-11-2009, 10:35 AM   #3
booder101
Registered User
 
Join Date: Oct 2009
Posts: 2
Default

Thank you for your reply. I did try changing the background color in Illustrator to white - but it only displays as white, but does not export as white (since there is no real white rectangle in the background). I can't create a white rectangle to be the background because I have many separate layers in my Illustrator file so I would have to create that background many times.

When exporting to png from Illustrator, it does prompt for Background color - giving options for Transparent, White, Black, Custom. Is there a way to access or assign the background color for the exported layer through scripting there?
Appreciate any help.
booder101 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:51 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.