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

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

Explorer ,
Jul 24, 2024 Jul 24, 2024

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.

TOPICS
Experiment , How-to , Import and export , Scripting
418
Translate
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
Explorer ,
Aug 08, 2024 Aug 08, 2024

is anyone help me please?

Translate
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 Expert ,
Aug 13, 2024 Aug 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?

Translate
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
Explorer ,
Aug 14, 2024 Aug 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.

Translate
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 Expert ,
Aug 14, 2024 Aug 14, 2024
LATEST

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
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