Skip to main content
Participating Frequently
Oct 4, 2006 12:57 PM UTC
Question

Export to PNG from Illustrator

Does anyone have the AIPNGFormatAction.h header file so I can export Illustrator to PNG. I have found the AIPDFFormatAction.h header and got it working but I need the parameters for setting the resolution of the PNG.
This topic is closed to new replies. Start a new post to keep the conversation going.

27 replies

A. Patterson
Inspiring
Jun 11, 2008 12:57 PM UTC
Interesting -- there wasn't a binary parameter in there? I assumed there'd b a struct of some sort for handling export-to-PNG options.

Have you looked at AIImageOptimization.h? There seems to be a way to rasterize art to a PNG using AIImageOptPNGParams, but maybe you've looked at this and ruled it out.
Translate
Participating Frequently
Jun 11, 2008 7:18 AM UTC
I created an action file for exporting to PNG from Illustrator and opened up the .aia file. Unfortunately it does not look like the action contains any parameters for resolution or transparency. I deciphered all the hex strings and 4 byte commands and it only contains the standard parameters for file name and location, format and extension. It may be an oversight by Adobe that it just uses the last setting when exporting.
Translate
Participating Frequently
May 21, 2008 9:39 AM UTC
Thanks very much for this info. I will give it a try.
Translate
A. Patterson
Inspiring
May 20, 2008 7:10 PM UTC
If you can record the export as an action, you can try saving it as an action set and opening up the resulting .aia file in text editor. It should display all the parameters used by actions for the action set. The only thing it's not super helpful is when a parameter expects a binary block, but the size of the binary block can sometimes point the way to the appropriate struct.
Translate
Participating Frequently
May 19, 2008 12:37 PM UTC
Thomas,

I never solved the issue. Adobe never replied to my emails requesting the header files for export PNG so I could get the parameters. In the end I bypassed the whole issue by exporting as PDF (where I can control all the parameters because I have the header files) and then converting the PDF to PNG using Adobe's PDF library (which we have licenced).

Obviously if you pre-setup the values for resolution etc manually before you run your code it retains the export values but if you have never exported as PNG then it always ends up as 300 dpi.

Let me know if you have any better luck in discovering the parameters for controlling resolution and transparency.

Robin
Translate
Toto RoToTO
Inspiring
May 19, 2008 11:13 AM UTC
Hello,

I have got exactly the same problem.
Here it is the snippet for for exporting the current layer of the artwork:

ASErr result;
AIActionParamValueRef valueParameterBlock = NULL;
ActionDialogStatus dialogStatus = kDialogOff;

result = AIActionManager->AINewActionParamValue(&valueParameterBlock);

if (valueParameterBlock)
{
// see AIDocumentation.h

result = sAIActionManager->AIActionSetString(valueParameterBlock, 'name', pathName);

result = sAIActionManager->AIActionSetString(valueParameterBlock, 'frmt', "Adobe PNG Format");

result = sAIActionManager->AIActionSetString(valueParameterBlock, 'extn', "png");

result = sAIActionManager->PlayActionEvent("adobe_exportDocument", dialogStatus, valueParameterBlock);

result = sAIActionManager->AIDeleteActionParamValue(valueParameterBlock);
}

It seems to work! but since the DialogStatusbox is not shown, how could I set programmaticaly export settings for PNG, such as background visibility and resolution.

Any help will be appreciated,
Best regards.

Thomas.
Translate