Copy link to clipboard
Copied
Hi
I have a 111 page file.
Within this file I have several modules, and I would like to create a function that allows me to choose the print modes for each module
For instance:
The "MANDATE" form starts on page 5 and ends on page 9.
On page 5 I created a hidden field (named "Text1" with the custom calculation script "event.value = event.target.page;"
The number 4 appears in the field.
I did the same on page 9 where I inserted a new field (named "Text2") with the same script and the result that appears in the field is 8.
Then, again on page 5, I inserted a new field (named "MANDATE") with the custom calculation script var s1 = this.getField ("Text1"). Value;
var s2 = this.getField ("Text2"). value;
event.value = "[" + s1 + "," + s2 + "]";
The result is [4,8].
I did the same for the "INFO PRIVACY" module which goes from page 10 to page 15, for the "AV1" module which goes from page 16 to page 17, "AV2" from page 18 to page 19 and "AV3" from page 20 on page 21
So, I have the fields "MANDATO", "INFO PRIVACY", "AV1", "AV2", "AV3" with the results respectively [4,8], [9,14], [15,16], [17, 18], [19,20].
I created a button on page 4 of the pdf and added this function
var pp = this.getPrintParams ();
pp.colorOverride = pp.constants.colorOverrides.blackandwhite;
pp.pageHandling = pp.constants.handling.fit;
var s1 = this.getField ("MANDATE"). value;
var s2 = this.getField ("INFO PRIVACY"). value;
var s3 = this.getField ("AV1"). value;
var s4 = this.getField ("AV2"). value;
var s5 = this.getField ("AV3"). value;
pp.printRange = [s1, s2, s3, s4, s5];
pp.NumCopies = 1;
pp.DuplexType = 2;
pp.printerName = "Adobe PDF";
pp.interactive = pp.constants.interactionLevel.silent;
this.print (pp);
Obviously it doesn't work
Please, someone is able to solve this problem.
Thank you in advance for your help
Copy link to clipboard
Copied
> I have to abandon the function with pp.printRange, right?
No, you can create an array of arrays for this.
Copy link to clipboard
Copied
Here's a simplified example of how it can work:
var s1 = Number(this.getField("Text1").value);
var s2 = Number(this.getField("Text2").value);
var s3 = Number(this.getField("Text3").value);
var s4 = Number(this.getField("Text4").value);
pp.printRange = [[s1,s2], [s3,s4]];
Remember, though, that the values you specify for printRange have to be zero-based, so if the values of these fields are 1-based you have to subtract 1 from them first.
Copy link to clipboard
Copied
The printRange property takes a 2D array, with each array having two values: The start page for that range and the end page.
Copy link to clipboard
Copied
this means that in printRange I have to indicate the number of the start page and the end page? So to indicate the page of the beginning of printing or the page of the end of printing, can I not recall the data contained in a field?
Copy link to clipboard
Copied
Sure you can. You can use either numbers or variables that have a Number value, but you have to do so in the correct format.
Copy link to clipboard
Copied
You should read this:
Copy link to clipboard
Copied
You can't use an array of strings for printRange.
Copy link to clipboard
Copied
So, I have to have to use this solution
var pp = this.getPrintParams ();
pp.colorOverride = pp.constants.colorOverrides.blackandwhite;
pp.pageHandling = pp.constants.handling.fit;
pp.firstPage = this.getField ("Text1"). value;
pp.lastPage = this.getField ("Text2"). value;
pp.DuplexType = 2;
pp.printerName = "Adobe PDF";
pp.interactive = pp.constants.interactionLevel.silent;
this.print (pp);
In the "Text1" field I have to insert the initial page and in "Text2" I have to insert the final page.
I have to abandon the function with pp.printRange, right?
Are there no alternatives?
Copy link to clipboard
Copied
No, not at all.
Copy link to clipboard
Copied
> I have to abandon the function with pp.printRange, right?
No, you can create an array of arrays for this.
Copy link to clipboard
Copied
Here's a simplified example of how it can work:
var s1 = Number(this.getField("Text1").value);
var s2 = Number(this.getField("Text2").value);
var s3 = Number(this.getField("Text3").value);
var s4 = Number(this.getField("Text4").value);
pp.printRange = [[s1,s2], [s3,s4]];
Remember, though, that the values you specify for printRange have to be zero-based, so if the values of these fields are 1-based you have to subtract 1 from them first.
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more