Print Page | Close Window

Wanting to refine a Print Button to scale to fit

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=3984
Printed Date: 15 Sep 2019 at 8:57am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Wanting to refine a Print Button to scale to fit
Posted By: Alex8888
Subject: Wanting to refine a Print Button to scale to fit
Date Posted: 05 Jun 2018 at 2:20pm
Hi folks, 

I've used this JavaScript 

this.print (false, this.pageNum,
this.pageNum);
to print the current page of the pdf. 

(I found the script in this article on Planet PDF which I found super-helpful:  http://www.planetpdf.com/developer/article.asp?ContentID=printing_current_page_with_jav&gid=6054 - http://www.planetpdf.com/developer/article.asp?ContentID=printing_current_page_with_jav&gid=6054 )

It works well, but it doesn't scale the page to fit on an 8.5 x 11 sheet of paper, so the margins are getting cropped off. I'm wondering if I can set it so that the page automatically scales to fit the paper, without having to open up the print dialog box and require the user to select that option manually. 

I've hunted around in this forum and on the web in general to see if anyone has asked this question before, but I haven't found what I'm looking for. 

I'd appreciate any ideas, directions or suggestions.

Many thanks,


-------------
---
Alex Hickey
Freelance Print Production Artist



Replies:
Posted By: gkaiseril
Date Posted: 07 Jun 2018 at 3:23am
That is a pretty old post. Adobe has has added the http://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2FPrintParams_properties.htm - PrintParams object that provides more control over printed output. You would use the http://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2FPrintParams_properties.htm%23TOC_constants2bc-5&rhtocid=_6_1_8_59_0_4 - pageHandling values.

 var pp = this.getPrintParams();

   pp.pageHandling = pp.constants.handling.fit;

   pp.firstPage = this.pageNum;

   pp.lastPage = this.pageNum;

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

   this.print(pp);



Posted By: Alex8888
Date Posted: 07 Jun 2018 at 9:14pm
This is awesome, gkaiseril. It works perfectly! Thank you, very, very, much! 

-------------
---
Alex Hickey
Freelance Print Production Artist



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net