• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
3

In CC Illustrator 2023 how do I create a Script to export each layer name as PDF name?

Community Beginner ,
Oct 25, 2023 Oct 25, 2023

Copy link to clipboard

Copied

Hello Adobe Community,

 

I have a multi layer Illustrator document and would like to write a script that saves one layer name as an individual PDF. If possible, I would like to be able to select the location where PDF will be saved so I can rewrite existing PDFs in that file path. I found a thread on this topic but the code does not work for me. 

Not sure if this is possible but I would like to also have a sepearete script that will also run this for all of the layers so this doesn't have to be repeated for each of the layers. 

 

Any help would be much appreciated! 

 

TOPICS
How-to , Import and export , Scripting

Views

275

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guide ,
Oct 25, 2023 Oct 25, 2023

Copy link to clipboard

Copied

I presume you want each layer saved as different PDFs and not all layers saved as the same PDFs but with different names. The script may be slow running, so test before running on a heavy document.

function main() {
    var folder1 = Folder.selectDialog();
    var doc1 = app.activeDocument;

    for (var i = 0; i < doc1.layers.length; i++) {
        app.selection = null;

        var layer1 = doc1.layers[i];
        layer1.hasSelectedArtwork = true;
        var selection = doc1.selection;
        
        var doc2 = app.documents.add();
        for (var j = 0; j < selection.length; j++) {
            selection[j].duplicate(doc2, ElementPlacement.PLACEATEND);
        }

        var PDF1 = new PDFSaveOptions();
        var name1 = layer1.name;
        var file1 = new File(folder1 + "/" + name1);
        doc2.saveAs(file1, PDF1);
        doc2.close(SaveOptions.DONOTSAVECHANGES);
    }
}

main();

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 27, 2023 Oct 27, 2023

Copy link to clipboard

Copied

Hello, 

I appreciate the quick response and code but I went ahead and used the code and ran into some issues: 

1. it only exports one PDF and resizes it so it does not match original, also the name of the file is different than visible layer??

2. is there a way to always export two layers (LOGO) and (CUT LINES) along with the other PDFs, these two layers do not change and are to be present in all exported PDFs

 

Attached are a few images that might help. 

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 31, 2023 Oct 31, 2023

Copy link to clipboard

Copied

The script was not written with invisible and locked layers in mind.  Can you share a test AI file (through a file sharing site)? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 05, 2023 Nov 05, 2023

Copy link to clipboard

Copied

Hello,

 

Below is a link to a sample file. If possible, I would like the two lower levels to be visible on the exported PDFs. Untimately it would be nice to run a script that keeps these two levels visible and then export each PDF one by one into a seprate file. 

 

Please see the https://drive.google.com/file/d/1MTni9FLzmXe2FsMDQaKW6m2-soj7JnKG/view?usp=drive_link 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 09, 2023 Nov 09, 2023

Copy link to clipboard

Copied

LATEST

For anyone interested in a solution. I found a brilliant script written by Matthew Ericson which exports as PDF or PNGs with optional layers visible. All you have to do is download the script and install it into your illustrator scripts library. Example use case. 

 

For more instructions please see this link. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines