9 Replies Latest reply on May 10, 2016 8:48 AM by Ugo G.

    [JS][CC2015] What's a good way to write a "save as intereactive pdf" script?

    Ugo G.

      Hello!

       

      i'm a beginner at scripting and i'm having a hard time finding clear explanations (jongware is great for the initiated but not me...).

      Anyways, i'm trying to make a script that will do the following :

      - save the active document as an interactive document

      - with some options (magnification, jpeg quality, layout etc.)

       

      On some docs it works well on some others i get the "Data is out of range" error, and i have no idea what to do with this or why it happens =/

      I've had hard time is setting the options. the syntax seems complicated to me. maybe thats what's causing the trouble.

       

      But here is the script i have so far. Feel free to correct =/

      app.scriptPreferences.version = 11.0
      var myDocument = app.activeDocument;
      var myFileName;
      if (myDocument.modified == false) {
          myFileName = myDocument.fullName + "";
          if (myFileName.indexOf(".indd") != -1) {
              var myRegularExpression = /.indd/gi;
              myFileNamePDF_Web = myFileName.replace(myRegularExpression, ".pdf");
          }
          with(app.pdfExportPreferences) {
              PDFJPEGQualityOptions.HIGH;
              PdfMagnificationOptions.FIT_PAGE;
              PageLayoutOptions.SINGLE_PAGE;
              colorBitmapCompression = BitmapCompression.zip;
              colorBitmapQuality = CompressionQuality.eightBit;
              colorBitmapSampling = Sampling.BICUBIC_DOWNSAMPLE;
              colorBitmapSamplingDPI = 300;
          }
          myDocument.exportFile(ExportFormat.INTERACTIVE_PDF, new File(myFileNamePDF_Web));
      } else {
          alert("Save your file before continuing");
      }