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

Save Untitled, unsaved INDD file to PDF?

LEGEND ,
Dec 10, 2018 Dec 10, 2018

Copy link to clipboard

Copied

I use this Javascript to save Illustrator files to PDF. How can I tweak it to work with InDesign? "var dest" is a variable supplied by Keyboard Maestro, a macro builder for Mac.

// save as

var dest = "%Variable%DND_SaveLocal%/%Variable%proofName%";

saveFileToPDF(dest);

function saveFileToPDF (dest) {

    var doc = app.activeDocument;

    if ( app.documents.length > 0 ) {

        var saveName = new File ( dest );

        saveOpts = new PDFSaveOptions();

        saveOpts.pDFPreset = "[Illustrator Default]";

//~         alert(saveName);

        doc.saveAs( saveName, saveOpts );

    }

}

Thank you for your help.

TOPICS
Scripting

Views

380

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

correct answers 1 Correct answer

Community Expert , Dec 10, 2018 Dec 10, 2018

Lets take var dest as the path of the pdf that you wanna export, so the following code should work for you

var dest = "Path to you pdf that is to be exported"

saveFileToPDF(dest);

function saveFileToPDF (dest) {

    var doc = app.activeDocument;

    if ( app.documents.length > 0 ) {

        var saveName = new File ( dest );

        var pdfPreset = app.pdfExportPresets.itemByName("[Illustrator Default]")

        if(!pdfPreset.isValid)

        {

              alert("Preset not found")

              exit(

...

Votes

Translate

Translate
Community Expert ,
Dec 10, 2018 Dec 10, 2018

Copy link to clipboard

Copied

Lets take var dest as the path of the pdf that you wanna export, so the following code should work for you

var dest = "Path to you pdf that is to be exported"

saveFileToPDF(dest);

function saveFileToPDF (dest) {

    var doc = app.activeDocument;

    if ( app.documents.length > 0 ) {

        var saveName = new File ( dest );

        var pdfPreset = app.pdfExportPresets.itemByName("[Illustrator Default]")

        if(!pdfPreset.isValid)

        {

              alert("Preset not found")

              exit()

        }

        app.activeDocument.exportFile(ExportFormat.PDF_TYPE, saveName, false, pdfPreset)

    }

}

-Manan

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
LEGEND ,
Dec 11, 2018 Dec 11, 2018

Copy link to clipboard

Copied

LATEST

Thank you! I'll give it a try.

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