4 Replies Latest reply on Sep 25, 2011 3:53 AM by John Hawkinson

    Running JavaScript in PDF files

    dwaynie Level 1

      Is it possible doing JS in PDF files? Adobe Illustrator has a very old and tedious way of generating graphs.

       

      If I could just use JS, I could perhaps use gRaphaël - what y'all think?

       

      --Dwayne

        • 1. Re: Running JavaScript in PDF files
          John Hawkinson Level 5

          Does your question have anything to do with InDesign?

          If not, you probably have the wrong forum.

           

          It's also a bit hard to understand exactly what you are asking. It is possible to embed Javascript in PDF files, but it's typically not a practical solution. It doesn't work with all PDF browsers. Javascript in PDF files is better relegated to things like animating the transition between pages, or interactive elements.

           

          It would help if you could write your question in more words, but I suspect you are asking a difficult question in the wrong forum. It is hard to tell.

           

          Try again, please?

          • 2. Re: Running JavaScript in PDF files
            dwaynie Level 1

            It just felt natural posting it here, since I make my PDFs in InDesign.

             

            I got this PDF here with some Adobe Illustrator graph. But every time my data changes, I have to go through the tedious task of recreating all my graphs from scratch.

             

            I was hoping there'd be a way to embed JS and CSS into my InDesign documents, so that I could pull in my latest numbers from an XML file, use gRaphaël to render them as supercool interactive graphs, and export it all to PDF.

             

            --Dwayne

            • 3. Re: Running JavaScript in PDF files
              [Jongware] Most Valuable Participant

              dwaynie wrote:

               

              It just felt natural posting it here, since I make my PDFs in InDesign.

               

              If this graph was created with Illsutrator, it'd make more sense to ask in the Illustrator forum.

               

              For what it's worth: Illustrator can deal with data-driven graphs, although I don't know to what extend; and if that fails, you could use Illustrator's Javascript interface to have it adjust your image for you.

               

              Neither option uses "Javascript inside a PDF": as far as I know, you cannot change a PDF through an embedded Javascript.

              1 person found this helpful
              • 4. Re: Running JavaScript in PDF files
                John Hawkinson Level 5

                I think the answer here is going to turn out to be "Technically yes, but practically no."

                Unfortunately getting there is going to be somewhat of a trip. I'm sorry I didn't ask the right question originally:

                 

                Exactly what is the consumer of this PDF file? Does it go to a printer? Is it on the web? Is it meant to be viewed in Preview? In Acrobat Pro? In Acrobat reader? Do you know? Do you care?

                 

                I do not think you will be able to use gRaphael in Acrobat. And even if you can (and I am wrong), I do not think you will be able to produce device-independent output.

                 

                I suspect you should be asking in the Acrobat forum.

                 

                Jongware wrote:

                If this graph was created with Illsutrator, it'd make more sense to ask in the Illustrator forum.

                 

                For what it's worth: Illustrator can deal with data-driven graphs, although I don't know to what extend; and if that fails, you could use Illustrator's Javascript interface to have it adjust your image for you.

                Unfortunately it's my understanding that Illustrator's scripting interface entirely neglects graphing. I've found this very frustrating because that's pretty much the only kind of thing I've wanted to automate in Illustrator. But I'm happy to be proven wrong.

                1 person found this helpful