Alert message before exporting PDF

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Alert message before exporting PDF

Viewing 12 reply threads
  • Author
    Posts
    • #91193
      Masood Ahmad
      Participant

      Hello Everyone,

      A very Happy New Year to you all :)

      Is it possible to have an Alert Message (with OK and Cancel buttons) when the user exports a PDF either by cmd+E or by File>Export option.

      The message can be like this:

      Have you check the file thoroughly before exporting the PDF?

      OK Cancel

      Clicking on the Cancel button will cancel the export.
      OK button will export the PDF

      JavaScript is preferable. AppleScript can also work.

      Thanks in advance.

      Masood Ahmad

    • #91229
      Masood Ahmad
      Participant

      Did I asked too much or is this impossible to achieve??

    • #91235
      David Blatner
      Keymaster

      It’s a good idea, but I don’t know any way to make InDesign do that. Maybe with APID from Rorohiko?

    • #91241
      Masood Ahmad
      Participant

      I too have the same thought but I’m sure people like Peter, Keith or Jongware can do that.

      It’s a big challenge…

    • #91244

      Try this one and put it in a start up folder. The alert will only have a yes and no. Maybe ok and cancel is possible with script-ui.

      #targetengine "doSomethingInCase"
      
      app.addEventListener("beforeExport", onExport);
      
      function onExport(event) { 
        var result = confirm("Have you check the file thoroughly before exporting the PDF?", true, "WARNING");
      
        if (result == true) {
          return
        };
        else (result == false) {
          event.stopPropagation();
          event.preventDefault();  
        };
        return;
      }
      

      Kai

      • #91261
        Masood Ahmad
        Participant

        Hi Kai,

        Hope you’re well and had a great weekend.

        Being a non-programmer, I’m trying to learn “JavaScript for InDesign” from a very long time. I have searched the web but didn’t get anything that can teach me the same. I have also gone through the course “InDesign-Scripting-Made-Easy” by Keith on Lynda, but fails to understand it. I then took a course in JavaScript, HTML and CSS from a reputed Institute. There I learned about the Web and the basics of JS. The instructors over there were unaware about the InDesign DOM and hence I’m left with no knowledge about the course I’m looking for.

        The Keith’s course gives the basic idea about the DOM but not in depth. For example, how to read DOM, how to capture the commands and options from DOM and utilize them in the JS. There is a huge .chm version of the DOM by Jongware, I have downloaded it but unable to read/understand it.

        Can you please guide me and recommend something in this regard. Meanwhile, I’m trying to get in touch with some Programmers, who are working on InDesign JavaScript.

        Thanks in advance,

        Masood

      • #91262

        Hi Masood,

        there exists always two kind of people: Graphic designers and scripters. Unfortunately most books and courses are written by scripters. So sometimes very dry stuff and hard to understand. I’m a graphic designer. So if I have problems, I have problems with JS and not the DOM ;-)

        To get a good start, I can recommend Peter Kahrels guide: https://shop.oreilly.com/product/9780596802530.do
        Allthough this isn’t up to date, it covers all important parts.

        Then Grant Gamble: https://www.amazon.de/InDesign-CS5-Automation-Using-JavaScript/dp/1460915380

        And at least: The Javascript course at lynda.com from Simon Allardice

        Notice one big thing:
        You cannot read those books from start to finish. There will always be a situation, where your script goes wrong or you do not understand what the author is tryin’ to say you. This time, the indesignsecrets or adobe-scripting forum is your friend, where you can post your code and people will give you in short an answer.

        hth
        kai

      • #91267
        Masood Ahmad
        Participant

        Thanks Kai, for your suggestions. I’ll go through these and hope to have a good start.

    • #91245
      Masood Ahmad
      Participant

      Million thanks for a quick solution. This is exactly I was looking for.

      It’s good to have so much talented people in this community.

      Once again many thanks.

    • #112589
      Masood Ahmad
      Participant

      Hi @Kai Rübsamen,

      Can the script be updated to work in Illustrator as well. I didn’t find Startup Scripts folder in illustrator.
      I want a pop-up message on Export and Close. Can you please look into this once again and suggest something.

      Thanks in advance!
      Masood

    • #112592

      Masood, sadly I’m not familiar with scripting in Illustrator, cause Illustrator has another object modell than InDesign.

    • #112739
      Masood Ahmad
      Participant

      Thanks Kai for responding back. I’ve uploaded the post on Adobe as well, let’s see what I’ll get.

    • #113680
      Masood Ahmad
      Participant

      Hi @Kai Rübsamen,

      Hope you’re well.

      Sorry to bother you again. But I need your help to refine the below code.

      I was looking for a script to run spell check before closing a file. So with some help from my colleague and using your code we created a code that is filling our requirements.

      I also tried to get some help from Adobe but there’s no response. So I have to come back to my favourite team.
      https://forums.adobe.com/thread/2521329

      The code is working fine i.e.
      a) A message pops-up when a user closes a file;
      b) If the user press No, then it open the Spell-Check dialog box;
      c) If the user press Yes, then the file gets closed; BUT
      d) It pops-up another message with Yes/No.

      Can the last pop-up message be disabled. Any help would be much appreciated.


      #targetengine "Reminder to run the Spell Check before Closing a file"

      app.addEventListener("beforeClose", onClose);

      function onClose(myEvent) {
      var result = confirm("Have you run the Spell-Check?", true, "WARNING");

      if (result == true) {
      return
      };

      else (result == false) {
      myEvent.stopPropagation();
      myEvent.preventDefault();
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
      app.menuActions.item("Check Spelling...").invoke();
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      };
      }

    • #113711
      Masood Ahmad
      Participant

      Any Luck :)

    • #114026
      Masood Ahmad
      Participant

      We further refine the script. The only problem I can see is that it either runs successfully on one system and only run once on another system. While troubleshooting, I noticed that if a user selects “Yes”, then the script don’t run the second time.

      Can anyone help me improve the script. Thanks in advance.


      #targetengine "inDesign"

      app.addEventListener("beforeClose", onClose);

      function onClose(e) {

      var result = confirm('Have you run the Spell-Check?', true, "WARNING");

      if (result == true) {
      app.eventListeners.everyItem().remove();
      return
      }

      else(result == false) {
      e.stopPropagation();
      e.preventDefault();
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
      app.menuActions.item("Check Spelling...").invoke();
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      }
      }

    • #114389

      If you use Windows, it’s easy to write a simple script like this one
      https://drive.google.com/open?id=1ssNOSW65Eb6AT3_6kw8ea3U62kcw65DU
      And it is easy to prepare for both AI and Indd

Viewing 12 reply threads
  • You must be logged in to reply to this topic.
>