6 Replies Latest reply on Jun 17, 2008 7:29 AM by MarkWalsh

    Code for PRINTING

      I have created a form with a button that runs a javascript to print the document (ACROFORM) and added the code to the button's Javascript Mouse Up :

      this.print(false, this.pageNum, this.pageNum);
      this.print({bUI: false, bSilent: true, bShrinkToFit: true});

      When I press the button, a "SAVE AS" window opens and says "Save the PDF file as..." Note : The console Debugging is empty (no error messages) and the default printer on Windows Print Parameters is my printer Canon.

      This other code also yields no results :

      var pp = this.getPrintParams();
      pp.interactive = pp.constants.interactionLevel.silent;
      pp.colorOverride = pp.constants.colorOverrides.mono;
      pp.firstPage = 0;
      pp.lastPage = 0;
      this.print(pp);

      Again, the same message and the same problem = DOES NOT PRINT.

      What is wrong?? Any clues?
      Thank you,

      Maleck
        • 1. Re: Code for PRINTING
          Patrick Leckey Level 3
          This code worked fine for me:

          var pp = this.getPrintParams();
          pp.interactive = pp.constants.interactionLevel.silent;
          pp.colorOverride = pp.constants.colorOverrides.mono;
          pp.firstPage = 0;
          pp.lastPage = 0;
          this.print(pp);

          It showed a security dialog notifying me that the document was trying to print, I said to allow it, and it printed the document. I am using Acrobat Pro 8.1.2.
          • 2. Re: Code for PRINTING
            Level 1
            okay, I have installed 8.12 and it worked fine for me too. Thank you for your reply,

            Cheers,
            Maleck
            • 3. Re: Code for PRINTING
              Has anyone been able to come up with the javascript under Document Actions and "Document Will Print" to set ShrinkToFit to false. I have the following script in a print button:

              this.print({bUI: false, bShrinkToFit: false});

              This works but if they don't use this button to print (vs File/Print) then I get a lot of printed documents that were ShrinkToFit which makes scanning of images with OCR more difficult.

              Help,
              Blair
              • 4. Re: Code for PRINTING
                is there a way to alter this so that it could automatically print a 'variable' that would be in the filename? For instance a file named "4 6 ee-235-912", only pages 4 and 6 would get printed (so page, ..., page, name space delimited)?

                And then I would like a way to make some sort of bat file or something, just a simple script that would do this function automatically (so is there a way to access the custom function/macro via the commandline? ie "acrobat.exe filename.pdf -o optionRunMyMacro"
                • 5. Re: Code for PRINTING
                  gkaiseril MVP & Adobe Community Professional
                  To put the file name on a PDF being printed you either need to add a field with the value of the file name at the time of printing (requires Standard, Professional, or Professional Extended not Reader), or add a field name when the PDF is created and a script to add the file name property to the field when the file is printed.

                  There are very few command line switches and running a batch process or function within a PDF is not one of them.
                  • 6. Re: Code for PRINTING
                    MarkWalsh Level 4
                    You can use a regular expression to return the first two sets of digits (that are separated by one or more spaces) in the name of the file (yourFileName)

                    var theRegEx = new RegExp(/^(\d+) +(\d+)/)
                    if (theRegEx.test(yourFileName)) {
                    var pageStart = RegExp.$1
                    var pageEnd = RegExp.$2
                    }