Copy link to clipboard
Copied
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();
});
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();
});
Copy link to clipboard
Copied
You should use the print method instead of saveAs.
Copy link to clipboard
Copied
It prints to a hold que, I can save to it manually. Its a postcript digital press.
Copy link to clipboard
Copied
The printer is not available under my printers
Copy link to clipboard
Copied
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();
});
Copy link to clipboard
Copied
Glad you fixed it, but three backslashes is not a meaningful escape sequence.
Copy link to clipboard
Copied
How do you mean, can you please explain in more details.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you very much try67! This will be very useful when I develop the more advanced scripts that I am working on.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now