Skip to main content
Participating Frequently
October 4, 2006
Question

Export to PNG from Illustrator

  • October 4, 2006
  • 26 replies
  • 21118 views
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 has been closed for replies.

26 replies

A. Patterson
Inspiring
June 11, 2008
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.
Participating Frequently
June 11, 2008
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.
Participating Frequently
May 21, 2008
Thanks very much for this info. I will give it a try.
A. Patterson
Inspiring
May 20, 2008
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.
Participating Frequently
May 19, 2008
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
Toto RoToTO
Inspiring
May 19, 2008
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.