• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

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

Community Beginner ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

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. 

TOPICS
Acrobat SDK and JavaScript

Views

106

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
community guidelines
Community Expert ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

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

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
community guidelines
Community Beginner ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

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

 Captura.PNG

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.

 

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
community guidelines
LEGEND ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

I don't see from your description what software is being used to actually handle the PDF. Is it being produced, downloaded, opened in Acrobat Pro? This code should work if a PDF is produced containing this JavaScript, downloaded, and opened in Acrobat Pro. Not in a browser, for sure. For more detail, please explain the components and processes for the "API" you mention.

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
community guidelines
Community Beginner ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

To handle the PDF I'm using the Oracle BI Publisher, I mean, we have a folder repository in BIP, and there we save the PDF templates, that were built in Adobe Acrobat Pro using form fields with the same name of the fields of the related ones in the datamodel. Later built a service just to go to this repository an get the url (follow the folder structure) where the document is in BIP, and download, I open it with Adobe Acrobat.

 

Step by step:

 

  1. Create a data model using BI Publisher where for example exists the field NAME.
  2. Create a template using Adobe Acrobat where link the form fields with the fields that I created in the data model in BIP. Like that: Captura.PNG
  3. Upload the template to the related folder in BI Publisher. (That's why the logic need to be in the template, I think, based on the form fields, and later apply it based on the values that are in DDBB)
  4. To get the document, call BIP using a service in an API to get the url where the document is.
  5. With the url, using also the service previously mentioned, download the file to my desktop.
  6. Open the file with Adobe. 

 

I had thought that it will not be possible use JavaScript sentences in that case, am I right? 

If can not do that, do you think there are other way to build this logic using Adobe Acrobat?

 

An also, other question, do you know how can I move text in the PDF, not included in any form field, to a form field? Maybe doing that I can manage the situation, conditioning this form field? Or also javascript is needed and this is impossible in my situation?

 

Thanks in advance for your help, is being very useful for me, because I started from scratch with Adobe and I'm getting crazy with the things that I need. 

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
community guidelines
LEGEND ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

I am not familiar with the Oracle product you mention, but it seems that at steps 3-4, an API made by Oracle is processing the file you create to provide a PDF to download. I think you want a general statement about APIs, but it is impossible to make one; each developer makes their own decisions, does their own work, and decides what will work and what will fail. But, in general

* If is possible that, when processing the file, that JavaScript is ignored or deleted.

* If you are looking for the JavaScript to run when the API does processing, it is not impossible, but it is very unlikely.

Bottom line: for support with an API contact the maker of the API.

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
community guidelines
Community Beginner ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

I think the problem is more the BI Publisher than the API, because API is just to pick up the file from the repository in BIP. 

 

So, do you see any alternative in Adobe Acrobat to show or hide a page based on a form field value, without javascript? I don't think so. 

 

Do you know how can we put text included the content of PDF, inside a form field?

 

Thanks 🙂

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
community guidelines
Community Expert ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

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

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
community guidelines
Community Beginner ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

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

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
community guidelines
Community Expert ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

LATEST

A validation script at a field will only activated in Acrobat when you change the value of the field.

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
community guidelines