5 Replies Latest reply on Feb 3, 2014 12:01 AM by CarlosCanto

    Dynamic Invoice with prompts

    RandyV86

      Hey Guys;

       

      i've been breaking my head over this for days now, i thought i could get this done without coding or scripting, but i can't figure it out.

       

      I have an Illustrator template file for my invoices, now, every time i make an invoice, i edit each text layer in the document, what i would like to make is an action that gives me prompts for every text field i need to edit, so when i press play or call the script i need to get a prompt: "Invoice date?" , i fill in the date, and the text field gets updated with that info. And then multiple prompts for all the info i need to add.

       

      Can anybody assist me in this or get me started ?

      I've been looking true the JS books from Adobe and Applescripts but i'm realy the biggest code noob you have ever known

       

      Thanks !

        • 1. Re: Dynamic Invoice with prompts
          CarlosCanto Adobe Community Professional & MVP

          start with the book 'Adobe Intro to Scripting', follow the samples, don't copy and paste, retype everything, it'll stick easier that way.

           

          for this example, make two text frames (type anything it won't matter), give them names, 'firstName' and 'lastName'. The script will prompt you for text, look for those text frames and replace their content with the provided text.

           

          var idoc = app.activeDocument;
          
          
          var title = 'Invoice Helper';
          
          
          var first  = prompt ('Enter First Name', 'Mickey', title);
          var last = prompt ('Enter Last Name', 'Mouse', title);
          
          
          // make sure you have two text frames named 'firstName' and 'lastName'
          var frameFirst = idoc.textFrames.getByName ('firstName');
          var frameLast = idoc.textFrames.getByName ('lastName');
          
          
          frameFirst.contents = first;
          frameLast.contents = last;
          
          • 2. Re: Dynamic Invoice with prompts
            W_J_T Level 4

            CarlosCanto wrote:

             

            make two text frames (type anything it won't matter), give them names

             

            Concerning this, when you type text in a text frame the name defaults to the text. However when you try to retrieve the name property you get nothing, until you go in and replace what is there with the same or something else. Just curious Carlos but do you know why it can't gather the text that is already applied to the name from the text data without replacing it even if it is the same data used to replace it?

            • 3. Re: Dynamic Invoice with prompts
              CarlosCanto Adobe Community Professional & MVP

              the text you see in the layers panel is a ''preview" of the frame's content, not the actual textFrame's name. TextFrames need to be explicitly named just like paths, groups, etc

              • 4. Re: Dynamic Invoice with prompts
                W_J_T Level 4

                Hi CarlosCanto thanks for responding. This is what I was referring to as described in post #2 (CS5.x). I typed "some text" on the page, the layers panel yes shows this as the preview for the item, but this data also resides in the name option. Yet until you cut and paste or retype the name back into the name option (after first making a change and closing the window, then reopening) it can not be retrieved. It just seemed odd that actual data is there originally but can't however be referenced via scripting concerning textframes and the name property.

                 

                name.png

                • 5. Re: Dynamic Invoice with prompts
                  CarlosCanto Adobe Community Professional & MVP

                  It just seemed odd

                  it is odd