6 Replies Latest reply on Apr 2, 2015 8:47 AM by MadMax4025

    Saving a review PDF


      Hi all,


      I'm just getting into Extendscript for FM 12 so bear with me.

      I have found the FM_Outputs_CondText file which does everything I need it to do except for I want the file to be saved as a review PDF. I've found the FCodes.KBD_SAVEASPDFREVIEW command and can get it to open the saveas dialog. However, I cannot for the life of me figure out how to interact with this. Any thoughts on how I can achieve the following process:


      1: Apply conditional text show/hide (included in FM_Outputs_CondText)

      2: Change output file name (depends on how I achieve step 3)

      3: Save as review pdf

      4: Move to next conditional text show/hide (included in FM_Outputs_CondText)


      Any suggestions of what to do or where to look would be amazing.

      (any FM scripter/user groups in Portland, OR?)


        • 1. Re: Saving a review PDF
          frameexpert Level 4

          Hi Corey,


          I don't have time to give you a detailed explanation, but here is some code to get you going on saving a review PDF.


          #target framemaker
          var doc = app.ActiveDoc;
          savePdf (doc);
          function savePdf (doc) {
              var saveParams, retParams, i = 0, pdfName;
               // Get a property list to return any error messages.
              retProps = new PropVals();
              saveProps = GetSaveDefaultParams();
              i = GetPropIndex (saveProps, Constants.FS_FileType);
              saveProps[i].propVal.ival = Constants.FV_SaveFmtPdf;
              doc.PDFJobOption = "Standard";
              doc.PDFGenerateForReview = 1;
              // Get the save name for the PDF and save it.
              pdfName = doc.Name.replace (/\.fm/i, ".pdf");
              doc.Save (pdfName, saveProps, retProps);



          • 2. Re: Saving a review PDF
            frameexpert Level 4

            A couple of things about the code: line 17 is where you can set the desired PDF Job Option file. I am not sure about line 19; I have never used this, but I am pretty sure this is the setting you are looking for to make a review PDF. Line 22 uses a regular expression to replace the .fm extension with .pdf.

            • 3. Re: Saving a review PDF
              frameexpert Level 4

              I just found the FM_Outputs_CondText.jsx that you are referring to. No offense to anyone at Adobe, but their code does not always reflect the best approach to doing things. If you need further help sorting this out, please post more questions to the forum. Thanks. -Rick

              • 4. Re: Saving a review PDF
                MadMax4025 Level 1

                Hi Rick,


                Thank you for the fast and detailed response. I knew it couldn't be THAT difficult to do what I wanted it to do, I'm just a amateur coder so it was not in my scope of knowledge yet. Your code worked exactly the way I wanted it to and I should be able to modify it from here to do what I want it to do. Now I just have a few other processes to figure out and I'm good to go (but they don't fit within this question so I'll post them elsewhere when I give up trying to figure it out myself). Thanks so much!



                • 5. Re: Saving a review PDF
                  frameexpert Level 4

                  Fantastic! I am glad it helped. Make sure you read this Scripting tips. It will help you as you learn. -Rick

                  • 6. Re: Saving a review PDF
                    MadMax4025 Level 1

                    Thanks Rick,


                    I'll check it out.