Skip to main content
Participant
October 13, 2020
Question

Show or hide a page based on a form field when the pdf is generated by API

  • October 13, 2020
  • 1 reply
  • 1749 views

Hello!

 

I'm new here, and also using Adobe, but I'm trust on some of you have the solution to my problem, because I spent days try to do, but when I download the document is exactly the same, I don't know if I'm putting the javaScript in the wrong side, or javaScript code is being ignored by the API...

So first of all, thanks in advance. 

 

My version of Adobe is Adobe Acrobat PRO 2017 and the thing is, I need to show a page to the document if a value of the form is equal to 3, in other case, then show another page and hide the previous one. 

Other thing that I can do is put the text in the document inside a form field, and condition the field with the same condition that I mentioned, but applied to fields, but I don't know who can I do that neither.

 

I don't want to use mouse up or something like that, the document need to be automatically generated with following these conditions.

 

Thanks again, 

 

Silvia. 

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
October 13, 2020

What API does you use? Where does you add the Javascript code?

Participant
October 14, 2020

I've tried to put in the related field inside the properties> validate>Run custom validation

 

var t1 = getTemplate("Page 5");

var t2 = getTemplate("Page 4");

// Add page 5 when is less than 0 other case, add page 4

if (GROSS_PREMIUM < 0) {

t1.spawn({nPage: numPages, bRename: true, bOverlay: false});

} else {

t2.spawn({nPage: numPages, bRename: true, bOverlay: false});

}

 

But it ignore my javascript code, also I tried, just to try, to put this inside the first condition: 

this.deletePages(4);

But continue doing nothing.

 

The other place where I put the code was in

 

In Will save Wil print, because the action need to be executed automatically. 

 

But nothing.

 

I'm creating the documents using Oracle BI Publisher to link Adobe templates (using the form fields) with a data model and get the data from database. Later built a service to get the url for all the documents that are in the repository of BIP for this specific data, and finally download the url that contains the document PDF.

 

Participant
October 14, 2020

Can you see the scripts when you open the form in Adobe Acrobat?


Yes, when I download the PDF and open it in Adobe, I can see it.