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

Can I use this.flattenPages(); to just flatten the first page of a document or a certain range?

Community Beginner ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Hi Everyone, 

 

I created a form for clients to fill. This form has 2 pages. The first page I would like to lock or flatten the data submitted once I am done my review and stamp it and not have the second page locked so that others can complete the  second page of the form and sign off. 

 

I have Acrobat DC Pro. 

 

Can I use the java scipt  "this.flattenPages(); " and have it only flatten the first page? Is there addition code I can use to limit the range of flatten?

 

I cannot use any add-ons and I am restricted to what I have for software. 

  

Thanks in advance. 

TOPICS
Acrobat SDK and JavaScript

Views

1.5K

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

correct answers 2 Correct answers

Community Expert , Sep 10, 2021 Sep 10, 2021

If you want to flatten just one page (lets say page 2) use like this:

this.flattenPages(1);

if you want to flatten range of pages lets say 1-3:

this.flattenPages(0,2);

Likes

Translate

Translate
Community Beginner , Sep 10, 2021 Sep 10, 2021

Thank you this worked. 

 

To flatten page 1 I used: this.flattenPages(0);

 

 

Likes

Translate

Translate
Community Expert ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Yes, the "flattenPages()" function has inputs for  start page and end page. So you can flatten any page range you want.

 

Here's the reference entry:

https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%...

 

 

However, this function will only work in Acrobat Pro. It will not work in Acrobat Reader, or pretty much any other PDF viewer. I would suggest that you make the fields ReadOnly instead.  

 

Another alternative is to use the Adobe Sign process, which allows fine control over the form distribution process, but unfortunately is pretty weak on the actual form fields and doesn't allow any scripting. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

this.flattenPages({nStart: 0, nEnd: 0});

this.flattenPages({nStart: 0, nEnd: 1});

this.flattenPages({nStart: 1, nEnd: 1});

 

All result in flattening every page, any suggestions?

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

That should not be the case. Can you share the actual file with us (before you flattened it, of course)?

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

I'll have to redact a bunch of items. 

 

In the mean time ill give a better break down of what I tried:

 

1. I have a email button, and added an extra "action" to run a javascript with the flatten commands. I assumed acrobat didnt like this then

2: New button with no other associated actions. 

 

And to be Specific about which version I have: Adobe Acrobat DC (21.005.20060) 

 

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

If you want to flatten just one page (lets say page 2) use like this:

this.flattenPages(1);

if you want to flatten range of pages lets say 1-3:

this.flattenPages(0,2);

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

LATEST

Thank you this worked. 

 

To flatten page 1 I used: this.flattenPages(0);

 

 

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