Skip to content

Resizing an Artboard in Adobe Illustrator for Transparent PowerPoint Backgrounds

Many moons ago in a land far away I created a process to get transparent backgrounds from slides so I could import them into Sony Vegas. This is something that people in the forums are still trying to figure out. However, I’ve run into some problems along the way.

From a batching perspective, which was what I was after, I forgot to mention last time that I’d do a Save As in PowerPoint and select EMF. I’d then answer that I wanted to export every slide. This would create a folder with each slide as a separate file named slide1.emf through however many slides I had.

On the Illustrator side, I perpetually forget how to do the batch operation. I have to open the Actions Window. I’d record the Export to PSD operation. This was as simple as creating the action turning on recording and doing an Export from the File menu. Once the action as created, I could use the batch operation in the menu at the upper right hand corner of the Actions menu to run an action on a set of files in a directory. The batch menu allowed me to select the directory for the source and a place to override the exports. With this I’d leave Illustrator running for a few minutes and I’d have my slides saved as PSD files – with transparency that Vegas could read. CS 6 now even lets me put that window in the background – previous versions required that I leave Illustrator as the application with the focus.

That all works good – except when I get errors exporting the files – I’ll either get "Photoshop file could not be saved" when I’m working from a source Illustrator (AI) file or more frequently in my scenario "Unable to export at this resolution. Please lower the resolution and try again." Of course, lowering the resolution didn’t help. As part of the debugging process I decided that I wanted to see if I changed the artboard size in Illustrator to match the slide if that would help. One would think this is easy, in fact there’s a menu option for it:

Yea, that option doesn’t record in an action (although it can be added manually through the menu in the upper right of Actions with Insert Menu Item (which raises a dialog that’s not a dialog). However, that won’t help because the Fit to Artwork Bounds option only works if the artboard is larger than the current art. If it’s not (as in my case I get an error message)

Arg. The funny part is that the error message is a red herring. It’s non-sense. It just won’t expand the artboard to fit the artwork.

I was looking for other options and ultimately stumbled on some script that didn’t work. It showed me one of the reasons I really hate JavaScript debugging:

If you do some digging, you’ll find that this error means that "Illustrator doesn’t like you. Please go away and never come back." There might be some error in translation but it’s pretty close. (Ok, it really means there was a parameter that was out of bounds.) However, I did eventually find a script that would work after some serious tinkering. Here’s what works:

#target Illustrator
function PowerPointArtBoard()
{
if (app.documents.length > 0)
{
var activeDoc = app.activeDocument;
var pageItemsCount = activeDoc.pageItems.length;
if (pageItemsCount>=1)
{
var artBoard = activeDoc.artboards[0];
var bounds = [-55, 665,665,125];
var artboards = activeDoc.artboards;
var newArtBoard = artboards.add(bounds);
artBoard.remove();
}
else
{
alert("there is no art in the active document");
}
}
else
{
alert ("there are no open documents");
}
}
PowerPointArtBoard();

To use it you run the Adobe ExtendScript toolkit and then save the resulting file into C:Program FilesAdobeAdobe Illustrator CS6 (64 Bit)Presetsen_USScripts. (Obviously check the path for version number and for the language you have installed.) Once you have installed this you can relaunch Illustrator and the script name (minus the extension) will show up in the File-Scripting menu. With that you can use the Actions-Insert Menu Item above as a part of your Action. This means you can change the artboard before your save/export.

Astute observers will realize that the bounds for the artboard are hardcoded. Yes they are. They’re designed to create the right artboard size for a PowerPoint .EMF export. I tried every form of figuring out how to get Illustrator to create the correct bounding box and realized that the scale was wrong. I decided that I didn’t care for my purposes. Ultimately, this approach will ensure that I get the right bounding box even if I don’t put the transparent box around the slide (as I indicated I was doing in the last post.)

Really insightful observers will realize that I’m creating a new artboard and then deleting the original. Yea, Illustrator doesn’t let you change the rectangle of the artboard programmatically. So this approach works since it makes the new artboard with the right dimensions the default artboard.

For the moment this creates a work around for the issue with illustrator not saving… I can go into Photoshop and open the Illustrator file and have Photoshop do the conversion. The major issue with this approach is that Photoshop doesn’t have a way to do batch operations so I have to do these imports/saves by hand. At least I can get the files into a transparent background Photoshop without having to manually remove the background.

19 Comments


Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this: