Skip to main content
Legend
July 16, 2025
Answered

How to duplicate an artboard and its entire contents in ExtendScript

  • July 16, 2025
  • 2 replies
  • 705 views

There does not seem to be a method to duplicate an artboard in Illustrator's scripting API. Artboards.add and Document.selectObjectsOnActiveArtboard can do something similar, but the developer needs to worry about whether the PageItem is editable.

 

Alternatively, it could find all PageItem's that are in the appropriate artboard area and duplicate them, but I don't want to do that.

 

I have tried to record the duplication of the artboard in an action, but it is not responding.

 

Is there any way to duplicate the artboard while programmatically specifying the coordinates of the artboard, without worrying about whether the artboard's contents are editable or not?

 

The reason I want to do that is because I want to change the position of the artboard as I wish, which will be generated by the artboard duplication.

Correct answer Kawano Shuji

Yes, it would be. My intention was to duplicate the artboards within the same document, but it will mostly be accomplished that way.

 

The `Unlock All` and `Show All` menu commands will select the PageItem that was the target of each, so it's relatively easy to restore.

 

If the script uses a manually reproducible method such as copy/paste, it may be possible to translate the opacity masks.

 

The problem is layers. This is prone to MRAP errors because the script has to check the locked/visible status of all layers one by one.

 

I will wait a little longer and if no direct means of using Duplicate Artboards can be found, I will try to develop based on your means. Because Duplicate Artboards has a `Move Locked and Hidden Artwork with Artboard` option.


Altough still you need to check locked layers, selecting Artboard Tool then, copying and pasting behave like "Duplicate Artboards" I supporse.


(function () {
	app.selectTool('Adobe Crop Tool');
	app.copy();
	app.paste();
})();

 

2 replies

sttk3Author
Legend
July 19, 2025

I submitted to UserVoice the Duplicate Artboards problem that motivated me to develop the script. Feel free to vote for it.

CarlosCanto
Community Expert
Community Expert
July 16, 2025

unless there's a relatively new api method I don't know about, I duplicate artboards the way you described it. I duplicate each item on the artboard

sttk3Author
Legend
July 17, 2025

Thank you for your response. There doesn't seem to be a way, but I will wait and hope that a more elegant way will be raised.

 

That being said, what are some of the factors that could cause a mistake in selecting and duplicating/translating the contents of the PageItems? For example the following, but what are the others?

 

  • PageItem locked
  • PageItem hidden
  • Layer locked
  • Layer visible false
  • Guide locked
  • Guide hidden
  • Whether it is an Opacity Mask
CarlosCanto
Community Expert
Community Expert
July 17, 2025

oh damn, yeah it starts getting complicated quickly. Depending on the requirements, I don't deal with every possible scenario if I don't have to.

 

what if you

1. collect visible/lock info for each item in a layer

    1.2 unlock/unhide all

2. select all

3. copy

4. Paste Remember Layers

5. switch to destination document

6. paste

7. restore visible/lock from saved info

 

guides could be excluded before copying

opacity mask are trouble

 

would that work?