Skip to main content
Zapt Works
Inspiring
July 24, 2024
질문

I'm looking for a script for a daily recurring workflow about Export Artboard as PDF

  • July 24, 2024
  • 2 답변들
  • 631 조회

Is there an easy way to save the screenshot and do the process whose link I wrote? When I want to do it as an action, it does not save the operations selected from the menu, such as "Delete All Artboards", to the action. Are there any friends who can write the flow I shared in the video as a script? Thank you in advance and waiting for your answers.


Kindly regards.

이 주제는 답변이 닫혔습니다.

2 답변

Disposition_Dev
Legend
August 13, 2024

instead of a video, could you write down the steps you want the script to take, as well as any decisions the script may need to make for certain steps if necessary?

Zapt Works
Zapt Works작성자
Inspiring
August 14, 2024

Of course.


open file manual with double click
Menu > Object > Unlock All because sometimes i forgot unlock some objects
Menu > Select > Deselect
Menu > Select > All on Active Artboard
Menu > Object > Lock
Menu > Select > All
Menu > Edit > Clear
Menu > Object > Unlock All

Artboards > Delete Empty Artboard
File > Export > Export for Screens...
"choose format" PDF
Export Artboard

 


I am doing same routine for too many times per day. So I need a jsx file. I can't do it with action because I can't assign the "delete empty artboards" command to action. Thank you very much if you can help.

Disposition_Dev
Legend
August 15, 2024

This is untested but should do the trick. And it needs some love in terms of pdf export options. unfortunately im not aware of any access to the "export for screens" dialog or functionality. But the same functionality should be doable with pdf save options. But im not sure what options you need for your use case.

function doDailyTask()
{
    var doc = app.activeDocument;
    app.executeMenuCommand("unlockAll");
    app.executeMenuCommand("deselectall");
    app.executeMenuCommand("selectallinartboard");
    app.executeMenuCommand("lock");
    app.executeMenuCommand("selectall");
    app.executeMenuCommand("clear");
    app.executeMenuCommand("unlockAll");
    app.executeMenuCommand("deselectall");
    deleteEmptyArtboards();
    exportPDF();
    
    function deleteEmptyArtboards()
    {
        var artboards = doc.artboards;
        for (var i = artboards.length - 1; i >= 0; i--)
        {
            doc.artboards.setActiveArtboardIndex(i);
            app.executeMenuCommand("selectallinartboard");
            if (doc.selection.length == 0)
            {
                doc.artboards.remove(i);
            }
            app.executeMenuCommand("deselectall");
        }
    }

    function exportPDF()
    {
        var exportOptions = new PDFSaveOptions();
        exportOptions.artboardRange = doc.artboards.getActiveArtboardIndex() + 1;
        //unfortunately, i dont believe we have script access to the export for screens dialog
        //so you will have to set the pdf options manually right here
        //heres the available options: https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions.html

        //export the active artboard
        var outFileName = doc.path + "/" + doc.name.replace(".ai", ".pdf");
        var outFile = new File(outFileName);
        doc.saveAs(outFile, exportOptions);
    }
}
doDailyTask();

 

Zapt Works
Zapt Works작성자
Inspiring
August 8, 2024

is anyone help me please?