Printing Range of Pages to Specific Printer Silently

New Here ,
Oct 07, 2017

Copy link to clipboard

Copied

Hello Everyone

Thank you to everyone in this forum, I have found everything most helpful. Great community. I am struggling though at the moment, with understanding the Javascript Reference Manual for Acrobat DC.

When a page opens I have a Javascript automatically run.

What I want it to do is print the last 2 pages of the PDF silently to a non default printer.

This is what I have so far. Can anyone tell me what I'm doing wrong or wether this is even possible?

I am not sure even where to state what pages I need.

this.print({bUI: false, bSilent: true, bShrinkToFit: true});

var pp = this.getPrintParams();

pp.interactive = pp.constants.interactionLevel.automatic;

pp.printerName = "EPSON XP-442 445 Series";

this.print(pp);

Thanks everyone for any help.

Kindest regards

Jon

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

675

Likes

Translate

Translate

Report

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

Printing Range of Pages to Specific Printer Silently

New Here ,
Oct 07, 2017

Copy link to clipboard

Copied

Hello Everyone

Thank you to everyone in this forum, I have found everything most helpful. Great community. I am struggling though at the moment, with understanding the Javascript Reference Manual for Acrobat DC.

When a page opens I have a Javascript automatically run.

What I want it to do is print the last 2 pages of the PDF silently to a non default printer.

This is what I have so far. Can anyone tell me what I'm doing wrong or wether this is even possible?

I am not sure even where to state what pages I need.

this.print({bUI: false, bSilent: true, bShrinkToFit: true});

var pp = this.getPrintParams();

pp.interactive = pp.constants.interactionLevel.automatic;

pp.printerName = "EPSON XP-442 445 Series";

this.print(pp);

Thanks everyone for any help.

Kindest regards

Jon

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

676

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 07, 2017 0
Most Valuable Participant ,
Oct 07, 2017

Copy link to clipboard

Copied

It's possible, but not like that. First of all, you're not defining the page range, and you're using two print commands, for some reason.

But more importantly, this can't be done just from a script that is located in the file itself. That would be a huge security issue if a PDF could just start printing itself without any user confirmation.

That's why it can only be done silently from a trusted context, e.g. a folder-level script that's installed on the user's local machine.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 07, 2017 0
New Here ,
Oct 07, 2017

Copy link to clipboard

Copied

Thanks very much for your help. It is much appreciated.

What if I had a button that prints a page range to a specific printer. Is that possible?

Id rather the printer dialogue box didn't appear however if it needs to due to security it would be fine.

You see at the moment I am able to print a range of pages with a button using Javascript, to the default printer without any dialogue box. However its not the default printer I wish it to go to but another printer installed on the system.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 07, 2017 0
New Here ,
Oct 08, 2017

Copy link to clipboard

Copied

Eureka!!!!

I think I have managed it thanks to this post that I struggled to find, and reworking the code.

https://acrobatusers.com/forum/javascript/javascript-print-button-range-works-full-document-prints/

It seems to be working great, just need to find out now how to have the two pages print on two sides. I think this is called duplex printing and Acrobat supports this is the printer does.

The code working for me is

var pp = this.getPrintParams();

pp.printerName = "EPSON XP-442 445 Series";

pp.firstPage = this.pageNum-1;

pp.lastPage = this.pageNum;

pp.interactive = pp.constants.interactionLevel.silent;

print(pp);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2017 0
try67 LATEST
Most Valuable Participant ,
Oct 08, 2017

Copy link to clipboard

Copied

Add this line of code:

pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge; // or DuplexFlipLongEdge

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2017 0