4 Replies Latest reply on Nov 11, 2016 8:44 AM by mattr2667470

    printing pdf from browser via javascript

    mattr2667470

      I have a product that opens up html documents in a new tab on the browser and then sends a simple javascript command to print the document.

       

      We are looking to move away from this approach, and would like to generate pdf's that then automatically print out.

       

      So this question is simply part of a scoping exercise, and apologies if I am asking in the wrong place. 

       

      So,

       

      1) Is it possible to embed some basic Javascript into a pdf template that we have automatically filled in, so that when the document is displayed in a browser, it automatically sends the print command to the browser?

       

      And if so

       

      2) Is it possible for us to attach (merge?) 2 or 3 product sheets to this generated template, so that with one print command I can print out the completed template and any required product sheets rather than having to open X tabs, one for the template and one for each product sheet that is required.

       

      Thanks

        • 1. Re: printing pdf from browser via javascript
          try67 MVP & Adobe Community Professional

          1) You can embed a simple script in your PDF file that tells the application that opens it to send it to the printer, yes. Whether or not it will work depends on the application or plugin used to open the PDF. The code to use is simply:

          this.print();

           

          2) If you can control how the PDF file is built then you can merge the documents on your end, embed the code I provided above in the merged file and then send it to the user, sure.

          1 person found this helpful
          • 2. Re: printing pdf from browser via javascript
            mattr2667470 Level 1

            Thanks. I will be able to control how the file is built, however the data sheets themselves are provided by 3rd parties. Is it possible to append existing files from various sources to the one I have created? (Ideally I want to print out my populated template, and then each datasheet without it recalculating any page numbers and so on)

             

            I assume that I would need a full version of Acrobat to do all this? (Need to be sure on the version / code I have to buy as the templates will be automatically populated via data from a web form), so this whole process will be automatic and (hopefully) seamless!

            • 3. Re: printing pdf from browser via javascript
              try67 MVP & Adobe Community Professional

              No, you can't do it with Acrobat. It's not a server-side application. You would need to find some other solution to merging the file on your end.

              • 4. Re: printing pdf from browser via javascript
                mattr2667470 Level 1

                Hmm ok. Well at least its part way there if I can get away from printing html and on to creating and filling in pdf's themselves.

                Sounds like it is possible anyway, I just need to hit google some more. Thanks