These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Javascript Button: Printing to a Network Fax

jerryrowe
Registered: Mar 23 2011
Posts: 7

Other print buttons on my documents work fine.
They print to locally installed printers, though.
This is the code I have on the button's properties (when clicked, it executes this JS):
 
var pp = this.getPrintParams();
 
pp.printerName = "the_local_printer_name";
pp.firstPage = 0;
pp.lastPage = 0;
pp.NumCopies = 1;
pp.interactive = pp.constants.interactionLevel.silent;
 
this.print(pp);
   
But when I put the Fax printer name in there, it doesn't work. This is because it is a network printer.
 
Is there a way to barely adjust this script so it will print? Or is there a shorter, better version I can do since it will be faxed? I don't know, I am totally new, and this is my first post.
 
I appreciate any and all help I can get on this.

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Are you using the network name of the printer and not the user displayed name?

Print out a listing of available printers:

var l = app.printerNames.length
for ( var i = 0; i < l; i++)
console.println("(" + (i+1) + ") " + app.printerNames[i]);

George Kaiser

jerryrowe
Registered: Mar 23 2011
Posts: 7
I am pretty sure I am using the network name for the printer, with all the forward slashes.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
If you run the script provided in the Acrobat JS debugging console, you will see the printer names as Acrobat JS expects them.

George Kaiser

jerryrowe
Registered: Mar 23 2011
Posts: 7
I tried looking for over an hour on Google, and I am embarrassed to say that I cannot figure out how to run code in the debugging console. I really am new to using Acrobat, but not to programming in general.

How do I run code in the console?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You could have created a button and add the code to the button action and then opened the JS debugger after clicking the button.

I would have started my search right at this site:

The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript) by Thom Parker. The process is also described in the Acrobat JS API Reference.

George Kaiser

jerryrowe
Registered: Mar 23 2011
Posts: 7
I got this:

i is not defined
1:Console:Exec
undefined
jerryrowe
Registered: Mar 23 2011
Posts: 7
(Also, reading the references you gave me in the meantime. Thanks for that!!)
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Make sure you highlight all of the text to run and not just the last line.

var l = app.printerNames.length;
for ( var i = 0; i < l; i++)
console.println("(" + (i+1) + ") " + app.printerNames[i]);



(1) Microsoft XPS Document Writer
(2) Microsoft Office Document Image Writer
(3) Generic / Text Only
(4) Adobe PDF
(5) \\uscgdtpw001\CHIP25E
(6) \\uscgdtpw001\CHIP25F
(7) \\uscgdtpw001\CHIP25G

true

George Kaiser

jerryrowe
Registered: Mar 23 2011
Posts: 7
I am really feeling how new I am right now, thanks. :)

Using the debugging console, I have verified that I was, in fact, using the correct printer name in my button.
This is what I have:


var pp = this.getPrintParams();

pp.printerName = "\\ServerName\Fax";
pp.firstPage = 0;
pp.lastPage = 0;
pp.NumCopies = 1;
pp.interactive = pp.constants.interactionLevel.silent;

this.print(pp);




Nothing happens when the button is pushed, sadly.

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
There should have a message about a security error and this method not being allowed, but this appears to be a bug in that Acrobat/Reader does not pickup this restriction.

Silent printing is only available using the trusted function and privileged operation.

From the Acrobat JS API Reference:

"Note:(Acrobat 7.0) Non-interactive printing can only be executed during batch, console, and menu events."

If you want to use this code, you need to create a trusted function and place that function in an Acrobat/Reader application folder. You will have to install that code on all user's computers.

George Kaiser

jerryrowe
Registered: Mar 23 2011
Posts: 7
Ah, I also discovered another thing while doing this, that I think might be helpful to share if anyone else ever has this problem.

The / is the escape character for adobe JS, so you have to double them up.

\\ServerName\Fax should be \\\\ServerName\\Fax
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Good catch, I do not use silent printing or silent saves to network drives. So I usually forget about that issue.

George Kaiser