Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Send file to Network Printer by Javascript

Explorer ,
Nov 03, 2016 Nov 03, 2016

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

});

TOPICS
Acrobat SDK and JavaScript , Windows
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Nov 04, 2016 Nov 04, 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();

});

Translate
Community Expert ,
Nov 03, 2016 Nov 03, 2016

You should use the print method instead of saveAs.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2016 Nov 03, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2016 Nov 03, 2016

The printer is not available under my printers

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2016 Nov 04, 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();

});

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 04, 2016 Nov 04, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2016 Nov 04, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 04, 2016 Nov 04, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 04, 2016 Nov 04, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 06, 2016 Nov 06, 2016
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines