Skip to main content
Inspiring
May 6, 2019
Question

How to export selection in a doc as png?

  • May 6, 2019
  • 2 replies
  • 884 views

Hi,

I am working on a plugin for CC 2019 that can export selection on a document as png.

I looked into APIs in the C++ SDK similar to this API from the Scripting SDK,

app.activeDocument.exportSelectionAsPNG(fileSpec);

But, I couldn't find one.

There are only options to export the whole document.

Am I missing anything?

This topic has been closed for replies.

2 replies

Inspiring
July 28, 2022

this works
app.activeDocument.exportSelectionAsPNG(File("C:/path/to/selection.png"));

Trying to set the resolution on this to 300ppi for a garment printer. 

Line taken from: 
https://community.adobe.com/t5/illustrator-discussions/how-to-do-quot-export-selection-quot-in-illustrator-cc-scripting/m-p/9889474#M97775

 

Alberto Franco
Participant
January 19, 2021

Did you manage to solve your issue? I also am trying to do something similar but cannot find the right API call. 

poortip87Author
Inspiring
January 19, 2021

Hi,

 

No, couldn't find anything in the C++ SDK to do this.

In the end, I implemented this by hiding everything except the selection, resizing the artboard to the selection, and then exporting the document.

The end result was the desired result.

 

You'll have to handle different scenarios such as multiple artboards etc.