Skip to main content
Zapt Works
Inspiring
Jul 24, 2024 4:24 PM UTC
Question

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

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.

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Disposition_Dev
Legend
Aug 13, 2024 6:57 PM UTC

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?

Translate
Zapt Works
Inspiring
Aug 14, 2024 6:45 PM UTC

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.

Translate
Disposition_Dev
Legend
Aug 15, 2024 6:27 AM UTC

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();

 

Translate
Zapt Works
Inspiring
Aug 8, 2024 3:40 PM UTC

is anyone help me please?

Translate