Skip to main content
heresha93876846
Inspiring
Nov 3, 2016 9:39 AM UTC
Answered

Send file to Network Printer by Javascript

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 is closed to new replies. Start a new post to keep the conversation going.
heresha93876846
heresha93876846Correct answer
Inspiring
Nov 4, 2016 9:21 AM UTC

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();

});

9 replies

heresha93876846
Inspiring
Nov 6, 2016 4:42 PM UTC

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

Translate
try67
Community Expert
Community Expert
Nov 4, 2016 12:53 PM UTC

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.

Translate
Legend
Nov 4, 2016 11:18 AM UTC

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.

Translate
heresha93876846
heresha93876846AuthorCorrect answer
Inspiring
Nov 4, 2016 9:21 AM UTC

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();

});

Translate
Legend
Nov 4, 2016 10:00 AM UTC

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

Translate
heresha93876846
Inspiring
Nov 4, 2016 10:08 AM UTC

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

Translate
heresha93876846
Inspiring
Nov 3, 2016 10:45 AM UTC

The printer is not available under my printers

Translate
heresha93876846
Inspiring
Nov 3, 2016 10:44 AM UTC

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

Translate
try67
Community Expert
Community Expert
Nov 3, 2016 10:14 AM UTC

You should use the print method instead of saveAs.

Translate