7 Replies Latest reply on Sep 28, 2011 7:24 PM by Neonphotos

    Keep ID file name when exporting PDF

    Neonphotos

      Hi eveyone,

       

      i want to export PDF from ID and keep the original name of ID,

      e.g. the original name of ID is "abc.idd", i would like the exported PDF would be "abc.pdf"

      Does anyone how to write this script, thanks in advance.

       

      Neon

        • 1. Re: Keep ID file name when exporting PDF
          csm_phil Level 4

          Hi Neon,

           

          Please try this below JS Code for windows.

           

           

          var myDoc = app.activeDocument;
          var myPath = myDoc.filePath;
          
          var myDocname = myDoc.name.split(".indd");
          
          app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File(new File(myPath+"\\"+myDocname.join(".pdf"))));
          

           

          thx

          csm_phil

          • 2. Re: Keep ID file name when exporting PDF
            Neonphotos Level 1

            Hi phil,

             

            Thanks again. Would you make it as AS as i am using mac,

            I just want to export a PDF with "Print Quality" presets and use the same name as original, thanks.

             

            Neon

            • 3. Re: Keep ID file name when exporting PDF
              [Jongware] Most Valuable Participant

              csm_phil unwittingly muddied the waters. Javascript is not "for windows", and his code doesn't contain anything Windows-specific. Javascript itself has the advantage it can run on both the Mac and Windows versions of InDesign.

              • 4. Re: Keep ID file name when exporting PDF
                csm_phil Level 4

                Hi Neon,

                 

                Hi Neon, What i understand Neon wants to expect the Apple script so i created the Apple Script code below.

                 

                Hi Jongware, i know the javascript is working on the both platform in Mac & Windows. However, what i understand Neon Expect the Apple script i have to written the apple script to export pdf.

                 

                 

                Please use the Apple script to Export pdf using "Press Quality" settings.

                 

                 

                set AppleScript's text item delimiters to ""
                tell application "Adobe InDesign CS4"
                    activate
                    set aDoc to active document
                    set myFileName to name of aDoc
                    set AppleScript's text item delimiters to ".indd"
                    set trimExtn to first text item of myFileName
                    set AppleScript's text item delimiters to ""
                    set aPath to file path of aDoc
                    set newpath to (aPath & trimExtn & ".pdf") as string
                
                    tell document 1
                        export format PDF type to newpath using "[Press Quality]" without showing options
                        --after export the document need to close please enable this line.
                        --close saving yes
                    end tell
                    display dialog "Done..." with icon 1
                end tell
                

                 

                 

                thx

                csm_phil

                • 5. Re: Keep ID file name when exporting PDF
                  [Jongware] Most Valuable Participant

                  Sorry -- I meant to say there is no reason to use Applescript, because your Javascript will work on all platforms.

                   

                  (You knew this but the OP clearly didn't.)

                  • 6. Re: Keep ID file name when exporting PDF
                    csm_phil Level 4

                    May be he will interest to learn apple script also.

                    • 7. Re: Keep ID file name when exporting PDF
                      Neonphotos Level 1

                      Hi Phil,

                       

                      Thanks for your help, but there is a message mentioned something like " requires the ending of a row, etc, but found" unknown symbol"

                      (I am not sure this cos my mac is in chinese, i just translated it myself) and the "." in ".pdf" is highlighted in the row of "set newpath to(aPath & trimExtn&".pdf")as string"

                      Any suggestions, thanks.

                       

                      Neon