Widgets for Adobe Acrobat : Selective Flattener

screen shot

Many PDF files contain comments and markups (collectively called "annotations") and form fields, placed by reviewers or filled-in and returned by a forms recipient. Often when archiving the PDF file you need to preserve some of these in a non-editable format; a process which Acrobat calls "flattening". Annotations live in a separate layer on screen which allows them to to be moved about, hidden and edited.

Flattening converts the visible appearance of the annotation into a content object on the PDF page just like any other, so it can no longer be edited using the commenting tools, and doesn't appear in the Comments list. When a form is flattened, the entries visible on screen become static text objects, and any empty fields are removed completely. The Document Message bar will of course go away too.

Within the Acrobat user interface you only have the option to flatten an entire file - all comments, links, markups and form fields will be flattened throughout the document. That may be OK for a simple form, but what if you have a couple of Text Replace comments you want to flatten and some Stamps or Highlights that you want to keep? What about flattening all the comments while keeping a set of form fields active on the same page?

Well, now you can!

With this free cross-platform JavaScript tool, you can add a new "Flatten" menu to the "Edit" menu, containing items to flatten everything or to selectively flatten only particular types of annotation* or form fields and over a page range of your choice.


Creative Commons License

The script is made available via Creative Commons Share-alike, so you can use it and modify it for personal and commercial purposes provided you do not resell the script itself as a commercial product. It works with Acrobat 8 and higher on Windows and OS X.


  • Flattening cannot be undone, but the tool doesn't save the file. If you make a mistake, close the file without saving and reopen it.
  • *Rich Media Annotations (video, SWF, 3D) are always affected by the selective flattener - this is a limitation of Acrobat - they will be converted into their poster images.
  • Links are not affected by the selective flattener.
  • Sticky notes, file and sound comments always flatten to their "icon" state even if open at the time. As the icons become useless, we remove them by default - though you can choose to keep them.
  • You can run the tool repeatedly to flatten different combinations of annotation on different page ranges.
  • The page range uses absolute numbering (1,2,3,...).
  • The tool is provided as-is; if you have any problems with it use the link below to contact us, but we do not provide any warranty.
  • Of course this tool is for Adobe Acrobat only - flattening files is not supported in Adobe Reader.
  • The menu items will activate when a PDF files is open, but are disabled when viewing a PDF Portfolio layout, as they do not support annotations or forms.
  • If a comment has replies, these will be removed if the parent comment is selected for flattening.

  • For the curious, the tool works by disabling the print flag for retained annotations, flattening the page range using an option which only affects printable items, then re-enabling the print flag. You can use the same principles to make other types of selection, such as all comments by a specific author, or all form fields with nonzero content.


To install the script, open the ZIP file from the link above and extract the .js file into your Acrobat JavaScript folder, which on Windows is usually found at:

/Program Files/Adobe/Acrobat ?.0/Acrobat/JavaScripts

or on a 64-bit machine, at:

/Program Files(x86)/Adobe/Acrobat ?.0/Acrobat/JavaScripts

On Mac systems, locate "Adobe Acrobat Pro.app" in your Applications folder, show the package contents, and extract the .js file into:


To check the correct folder location (for all operating systems and customized installs), open Acrobat and press CMD-J or Ctrl-J to open the interactive console, clear the contents, type


select that text and press CMD-Enter or Ctrl-Enter. The path to use will be shown in the console.

Once installed, restart Acrobat and you will have an Edit > Flatten menu whenever there's an open document. You can of course modify the script for your own purposes, and we've commented it to show which part does what. Restart Acrobat if you change the script, as they're only loaded when the application initializes. If the menu doesn't appear after you've changed the code, check the JS console for errors. It'll tell you the line number with the mistake on.


If you're using Acrobat XI and get a crash message "An internal error occurred" when clicking the Flatten Forms and Comments menu item, then make sure you have the correct JavaScript permissions. Open Acrobat's preferences (CMD/Ctrl-K), and in the JavaScript category ensure that "Enable menu items JavaScript execution privileges" is ticked.