Skip to main content
heresha93876846
Inspiring
November 3, 2016
Answered

Send file to Network Printer by Javascript

  • November 3, 2016
  • 7 replies
  • 3507 views

I have a trusted function that saves a file to my network printer. But it doesnt work, I get this error:

"The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."

This is my code:

// Xerox = Send the file to the Xerox Printer

var xerox = app.trustedFunction( function()

{

app.beginPriv();

var xeroxPath = "\\\out\\spool\\print\\Xerox\\";

this.saveAs(xeroxPath + this.documentFileName);

app.alert("PDF is sent to the printer",3)

    

app.endPriv();

});

This topic has been closed for replies.
Correct answer heresha93876846

Ok, I found the solution. In windows map the  "\\\out\\spool\\print\\Xerox\\" to a new network Drive. In my case I mapped it to X: so the code becomes:

// Xerox = Send the file to the Xerox Printer

var xerox = app.trustedFunction( function()

{

app.beginPriv();

var xeroxPath = "x:\\";

this.saveAs(xeroxPath + this.documentFileName);

app.alert("PDF is sent to the printer",3)

   

app.endPriv();

});

7 replies

heresha93876846
Inspiring
November 6, 2016

Thank you very much try67! This will be very useful when I develop the more advanced scripts that I am working on.

try67
Community Expert
Community Expert
November 4, 2016

To find the correct path syntax of a specific location put a PDF file in that folder, open it in Acrobat and then execute this code in the JS Console:

this.path;

It will output the file's full path. That's the path you need to put in your script.

Legend
November 4, 2016

In a string "\\" means one backslash. You have that a lot. You have THREE. Why? I suspect you wanted to mean \\. But "\\\o" doesn't mean anything.

heresha93876846
heresha93876846AuthorCorrect answer
Inspiring
November 4, 2016

Ok, I found the solution. In windows map the  "\\\out\\spool\\print\\Xerox\\" to a new network Drive. In my case I mapped it to X: so the code becomes:

// Xerox = Send the file to the Xerox Printer

var xerox = app.trustedFunction( function()

{

app.beginPriv();

var xeroxPath = "x:\\";

this.saveAs(xeroxPath + this.documentFileName);

app.alert("PDF is sent to the printer",3)

   

app.endPriv();

});

Legend
November 4, 2016

Glad you fixed it, but three backslashes is not a meaningful escape sequence.

heresha93876846
Inspiring
November 4, 2016

How do you mean, can you please explain in more details.

heresha93876846
Inspiring
November 3, 2016

The printer is not available under my printers

heresha93876846
Inspiring
November 3, 2016

It prints to a hold que, I can save to it manually. Its a postcript digital press.

try67
Community Expert
Community Expert
November 3, 2016

You should use the print method instead of saveAs.