5 Replies Latest reply on Mar 12, 2016 7:06 PM by OzSanta2

    Requesting assistance with printing document from mac

    OzSanta2 Level 1

      G'day Javacripters

       

      Using Acrobat Pro DC for Mac.

       

      I've only use Java to add barcodes and text boxes to my Applescript Objective C application, but would like to see if it's possible to directly set print settings, and print every page of my documents using Java. I've searched, but cannot find an answer.

       

      Specifically, I want to set the following properties...

       

      Printer : largePagePrinter as variable

      Pages to Print : All

      Size : Actual Size

      Auto portrait/landscape : true

      Tile Scale :100%

      Overlap : 0.5"

      Cut Marks : true

      Tile only Large Pages : true

      Orientation : Portrait

      Auto-rotate pages within each sheet : true

       

      Page Setup dialog

      Format for : largePagePrinter as variable

      Paper Size : largePaperSize as variable

      Scale : 100%

       

      At the moment I'm using the GUI to set each property, and it's slow, particularly for the separate Page Setup dialog, and we're processing 200 plus pdf's a day.

       

      Is this possible? And if so, some guidance on coding would be appreciated.

       

      Regards

       

      Brian Christmas

        • 1. Re: Requesting assistance with printing document from mac
          try67 MVP & Adobe Community Professional

          I don't think it's possible to set all of these parameters with a script.

          You need to carefully study the PrintParams object to see what's possible.

          • 2. Re: Requesting assistance with printing document from mac
            OzSanta2 Level 1

            Thanks try67

             

            I managed to find some documentation, and think I can get away with setting just a few of the above parameters.

             

            I've copied and pasted, but the script fails.

             

            If anyone could tell me where and why, I'd be grateful.

             

            tell application "Adobe Acrobat"

              activate

              tell document 1

              say 1

              set javaScriptTwo to my Add_Printer_Parameters(CountOfPages)

              say 2

              do shell script ("sleep 1")

              do script javaScriptTwo

              say 3 # Does not say 3, but an error trap gives result at end

              end tell

              end tell

             

            on Add_Printer_Parameters(CountOfPages)

              set Params to ""

              set Params to Params & "var pp = this.getPrintParams();" & return

              set Params to Params & "pp.printerName = " & theLargePagePrinter & ";" & return

              set Params to Params & "pp.interactive = pp.constants.interactionLevel.automatic;" & return

              set Params to Params & "pp.tileMark = pp.constants.tileMarks.west; " & return

              set Params to Params & "pp.tileOverlap = pp.constants.36; " & return

              set Params to Params & "pp.tileScale = pp.constants.1; " & return

              set Params to Params & "pp.fontPolicy = pp.constants.fontPolicies.everyPage;" & return

              set Params to Params & "pp.useT1Conversion = pp.constants.usages.auto; " & return

              set Params to Params & "fv = pp.constants.flagValues;" & return

              set Params to Params & "// or pp.flags |= fv.setPageSize;;" & return

              set Params to Params & "pp.flags = pp.flags | fv.setPageSize; " & return

              set Params to Params & "this.print(pp);" & return

              set javaScript to Params

              return javaScript

              end Add_Printer_Parameters

             

             

            gives this error

             

            printAdobeAcrobat 2 Adobe Acrobat got an error: "var pp = this.getPrintParams();

            pp.printerName = Large Page Printer;

            pp.interactive = pp.constants.interactionLevel.automatic;

            pp.tileMark = pp.constants.tileMarks.west;

            pp.tileOverlap = pp.constants.36;

            pp.tileScale = pp.constants.1;

            pp.fontPolicy = pp.constants.fontPolicies.everyPage;

            pp.useT1Conversion = pp.constants.usages.auto;

            fv = pp.constants.flagValues;

            // or pp.flags |= fv.setPageSize;;

            pp.flags = pp.flags | fv.setPageSize;

            this.print(pp);

            " doesn’t understand the “do script” message.

            error number -1708

            • 3. Re: Requesting assistance with printing document from mac
              OzSanta2 Level 1

              After entering my reply above, I realised I had not encased the Printer Name in quotes, however, this has not resulted in a working script. So, still asking for advice, probably regarding formatting of the 'fv' section.

               

              printAdobeAcrobat 2 Adobe Acrobat got an error: "var pp = this.getPrintParams();

              pp.printerName = \"Large Page Printer\";

              pp.interactive = pp.constants.interactionLevel.automatic;

              pp.tileMark = pp.constants.tileMarks.west;

              pp.tileOverlap = pp.constants.36;

              pp.tileScale = pp.constants.1;

              pp.fontPolicy = pp.constants.fontPolicies.everyPage;

              pp.useT1Conversion = pp.constants.usages.auto;

              fv = pp.constants.flagValues;

              // or pp.flags |= fv.setPageSize;;

              pp.flags = pp.flags | fv.setPageSize;

              this.print(pp);

              " doesn’t understand the “do script” message.

              error number -1708

              • 4. Re: Requesting assistance with printing document from mac
                try67 MVP & Adobe Community Professional

                I can't help you with the AS code, but in JS one you should remove the

                back-slashes before the quotes in the printer name.

                • 5. Re: Requesting assistance with printing document from mac
                  OzSanta2 Level 1

                  Thanks try67, but the back slashes are just Applescripts way of including a quotation mark.

                   

                  The script I ended up with, that works, is...

                   

                  on Add_Printer_Parameters()

                    set Params to ""

                    set Params to Params & "var pp = this.getPrintParams();" & return

                    set Params to Params & "pp.printerName = \"" & theLargePagePrinter & "\";" & return

                    set Params to Params & "pp.interactive = pp.constants.interactionLevel.automatic;" & return

                    set Params to Params & "pp.tileMark = pp.constants.tileMarks.west; " & return

                    set Params to Params & "pp.tileOverlap = 36; " & return

                    set Params to Params & "pp.tileScale = 1; " & return

                    set Params to Params & "pp.fontPolicy = pp.constants.fontPolicies.everyPage;" & return

                    set Params to Params & "pp.useT1Conversion = pp.constants.usages.auto; " & return

                    set Params to Params & "fv = pp.constants.flagValues;" & return

                    set Params to Params & "pp.flags =  fv.setPageSize; " & return

                    set Params to Params & "this.print(pp);" & return

                    set javaScript to Params

                    return javaScript

                    end Add_Printer_Parameters