Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Export pdf in Original Folder

Return to Member Forum

  • Author
    Posts
    • #89612
      Kathy Cote
      Member

      Someone would have a script that export the InDesign file in pdf open but in the same folder as the document original?

      Thanks for your help!

      this is my code:

      var myFilePath;
      var myFile;
      var allDocs = app.documents;
      var myDoc;

      if (app.documents.length == 0) {
      alert(“Il ni a aucun document ouvert”);
      exit();
      }

      for (var i = 0; i < allDocs.length; i++) {
      myDoc = allDocs[i];
      //I want to change this bellow code
      var myFilePath = “/Volumes/Travaux/Travaux_Studio/Sidlee/Sidlee New York/FOREVERMARK/Y100166A_OOH/Worfiles/Y100166A_Philadelphia_OOH/Philadelphia_Station/¬PhiladelphiaStation_Domination_Resume/” + myDoc.name.replace(/indd$/, “pdf”);

      var myFile = new File(myFilePath);
      myDoc.exportFile(ExportFormat.pdfType, myFile, false, “LR-Bleed-Crops-Slug”);
      }

      while (app.documents.length > 0) {
      app.activeDocument.close(SaveOptions.yes);
      }

    • #89625
      Kathy Cote
      Member

      Ok I have my working code. I would now add “_LR” at the end of the name of the pdf. I tried several things but it does not work. Can someone help me with this?

      while(app.documents.length>0){
      var myDoc = app.activeDocument;
      myDoc=myDoc.filePath+”/”+myDoc.name.split(“.indd”).join(“.pdf”);
      //alert(myDoc);
      var exportfile=new File(myDoc);
      app.activeDocument.exportFile(ExportFormat.pdfType, exportfile, false, “LR”);
      app.activeDocument.close();
      }

    • #89628
      Peter Kahrel
      Participant

      You should probably use the preset object, not a string. So instead of ‘LR’, use

      app.pdfExportPresets.item(‘LR’);

      Peter

    • #89631

      If I understand the question correct, the name of the preset is “LR-Bleed-Crops-Slug” and the pdf should get “_LR” as part of the name?

      I would:
      1. Check, if the preset exists
      2. Check, if the current document was saved before (otherwise there is no file path) and even modified
      3. Make a reference to the new file name and file path
      4. Export with the preset
      5. Close without saving

      // your preset name
      var pdfPreset = app.pdfExportPresets.itemByName("LR-Bleed-Crops-Slug");
      if (!pdfPreset.isValid) {  
        alert("Your preset doesn’t exist!");
        exit();
      }
      
      while (app.documents.length) {
        var curDoc = app.activeDocument;
      
        // check if the doc was saved or modified
        if (!curDoc.saved || curDoc.modified) {
          alert ("Save your doc before!");
          exit();
        }
      
        // built the PDF name
        var pdfName = curDoc.name.replace(/\.indd$/i,"_LR.pdf");
      
        // path to the folder of the indd-file
        var fPath = curDoc.filePath;
      
        // reference to the new file
        var pdfFile = new File(fPath + "/" + pdfName);  
      
        // export the current file …
        curDoc.exportFile(ExportFormat.pdfType, pdfFile, false, pdfPreset);
      
        // … and close the document
        curDoc.close(SaveOptions.NO);
      }
      

      Kai

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
Forum Ads