Highlighted

pageHandling fit to page size

New Here ,
Oct 29, 2020

Copy link to clipboard

Copied

I am creating a print button to automatically print a document with mixed pages sizes.

The printer has both Letter and Legal size paper available in different trays.

How can use javascript to fit a page that is 7" x 12" to Legal size paper but a page that is 6 1/2" x 8" to Letter size paper?

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

A script can't choose the paper size to print to, unless you have different printers for each size, and then you could specify the printer name in each print command. What you're describing will require a much more complicated script, though.

TOPICS
Acrobat SDK and JavaScript, Print and prepress

Views

46

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

pageHandling fit to page size

New Here ,
Oct 29, 2020

Copy link to clipboard

Copied

I am creating a print button to automatically print a document with mixed pages sizes.

The printer has both Letter and Legal size paper available in different trays.

How can use javascript to fit a page that is 7" x 12" to Legal size paper but a page that is 6 1/2" x 8" to Letter size paper?

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

A script can't choose the paper size to print to, unless you have different printers for each size, and then you could specify the printer name in each print command. What you're describing will require a much more complicated script, though.

TOPICS
Acrobat SDK and JavaScript, Print and prepress

Views

47

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 29, 2020 0
Most Valuable Participant ,
Oct 29, 2020

Copy link to clipboard

Copied

Use this code:

var pp = this.getPrintParams();
pp.pageHandling = pp.constants.handling.fit;
this.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 29, 2020 0
New Here ,
Oct 29, 2020

Copy link to clipboard

Copied

Unfortunately, this fits only to the paper in tray 1 of the printer (which is Letter).

I need to fit page by page to the next larger size.

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 29, 2020 0
Most Valuable Participant ,
Oct 29, 2020

Copy link to clipboard

Copied

Do you mean that you want to select the printer based on the page size? If so, try this:

 

var pp = this.getPrintParams();
fv = pp.constants.flagValues;
pp.flags = pp.flags | fv.setPageSize;
this.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 29, 2020 0
New Here ,
Oct 29, 2020

Copy link to clipboard

Copied

If I understand the API reference correctly, the setPageSize flag tells Acrobat to select the paper based on the page size. That's not exactly what I need to do.

I need to go page by page and choose what to do based on the actual size in the pdf file...

So page 1 is 8 1/2" x 11" setPageSize flag and print it to Letter.

Page 2 is 6 1/2" x 8" use PageHandling.fit to scale it to Letter.

Page 3 is 8 1/2" x 14" setPageSize flag and print it to Legal.

Page 4 is 10" x 16" - ??? I want this to fit to Legal but I don't know how. If I use PageHandling.fit it scales to Letter

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 29, 2020 0
Most Valuable Participant ,
Oct 29, 2020

Copy link to clipboard

Copied

A script can't choose the paper size to print to, unless you have different printers for each size, and then you could specify the printer name in each print command. What you're describing will require a much more complicated script, though.

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 29, 2020 0
New Here ,
Oct 29, 2020

Copy link to clipboard

Copied

I appreciate your help.

But it would seem that a good addition to the Javascript api for Acrobat would be a way to specify the pag size that handling.fit resizes to.

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 29, 2020 0
Most Valuable Participant ,
Oct 29, 2020

Copy link to clipboard

Copied

I agree, but it's not up to me... You can suggest it to Adobe here: https://www.adobe.com/products/wishform.html

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 29, 2020 0
New Here ,
Oct 29, 2020

Copy link to clipboard

Copied

Ok, different question - in the print dialog you can set a custom scale for printing.

Is there a javascript equivalent for that?

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 29, 2020 0
try67 LATEST
Most Valuable Participant ,
Oct 29, 2020

Copy link to clipboard

Copied

Only if you print using the Tile option.

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 29, 2020 0