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

"Restrict Editing"-like option that works with flattenPages()?

Community Beginner ,
May 29, 2019 May 29, 2019

Copy link to clipboard

Copied

I have a client that has requested a fillable pdf be both password protected against editing non-form items but will also flatten the forms on save (I currently have that function as a button fyi). I know the usual security settings causes flattenPages() to fail. Are there any alternatives I can run with javascript to achieve a similar result?

Push come to shove, I'd also settle for a method that locks editing without offering the option to enter a password at all. I'm trying to keep the pdf as friendly as possible for potentially computer-illiterate end users, so special saving methods to flatten the form are out.

Any tips are greatly appreciated! I don't usually use pdfs for anything other than sending artwork to printers, I'm a bit new to all of this.

TOPICS
Acrobat SDK and JavaScript

Views

444

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 ,
Jun 03, 2019 Jun 03, 2019

Copy link to clipboard

Copied

Once you've restricted modifying the PDF, flattenPages won't work since it changes the document and you've secured the file to prevent exactly that... and it'd never work for you in Reader because Reader can't modify the PDF in that way.

Do you need to flatten the file or do you just need to prevent changing the filled in data at some point when the user determines that they are done filling it. You don't want to attach such a script to the willSave action because the user may not be done but may want to save their work... at least not without prompting.

If you don't need to actually flatten the fields, just set them all to read-only based on some action. With the file secured, they become uneditable.    

Votes

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 ,
Jun 05, 2019 Jun 05, 2019

Copy link to clipboard

Copied

One method for flattening that gets around security and rights restrictions is to print the PDF to a file. Basically re-frying it, which while not recommended for best quality, will do the trick.

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

Votes

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 ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

This is an old post, but I wanted to follow up or acrchival purposes for anyone else coming across this since I've gotten this to work. This is without using flattenPages(), though I can't make much more sense of it anymore since it's been so long. Hope it helps. 🙂

 

Button action:

  • Mouse up, Exacute a menu item
  • Run a JavaScript
    • var fields = ["Field Name 1", "Field Name 2"]; for (var i in fields) { var f = this.getField(fields[i]); if (f==null) { console.println("ERROR! Can't find: " + fields[i]); continue; } f.readonly = true; }
  • Run a JavaScript
    • event.target.fillColor = color.white; this.getField("Save").display = display.hidden; app.execMenuItem("SaveAs");

Votes

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 ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

It's very easy to get around that. You can change the fields back to being editable, or even just edit their contents directly using a script or importing a data file, even if they are set as "read-only".

Votes

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 ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

LATEST

I'm sorry can you please clairfy, get around what?

Votes

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