Skip to main content
Inspiring
September 29, 2023
Answered

Replace pages

  • September 29, 2023
  • 1 reply
  • 720 views

Hi
I have a 26 page pdf file.
On page 2 I created a field called "one customer start" where the n° 1 appears
On page 26 I created a field called "customer end donation glossary" where the n° 25 appears

Then I created this function to insert into a button on the front page to replace the pages of the file from page 2 to page 26 with a 25-page pdf file called SURNAME DOC CUSTOMER

I created a field called "SURNAME"

Finally I created this function

var s1=this.getField("one customer start").value;
var s2=this.getField("customer end donation glossary").value;
var s4=this.getField("SURNAME").value;
this.replacePages({cPath:"/C/Users/Name Surname/Documents/AUXILIA/practices/"+s4+"/INSURANCE/"+s4+" DOC CUSTOMER.pdf",nStart:s1,nEnd:s2});

This error appears on the console:
TypeError: Invalid argument type.
Doc.replacePages:4:Console undefined:Exec
===> nEnd parameter.
undefined

Please, can someone help me understand where I made the mistake?
Thank you

 

This topic has been closed for replies.
Correct answer try67

But you'll need to change the value of the fields... If you want to replace all pages then simply use 0 and this.numPages-1. If you want to change just the pages where these two fields are located then you could use their page property, instead of their values.

1 reply

try67
Community Expert
Community Expert
September 29, 2023

The values of the page numbers in scripts are zero-based, so if the value of your fields are 1-25 then you need to deduct 1 from them. I don't understand why you're using field values for this, though... Why not simply enter the page numbers directly?

ENE5CD9Author
Inspiring
September 29, 2023

because if in the future I need to add pages to the file I don't have to change the page number in the formulae

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 29, 2023

But you'll need to change the value of the fields... If you want to replace all pages then simply use 0 and this.numPages-1. If you want to change just the pages where these two fields are located then you could use their page property, instead of their values.