How can I prevent the editing of PDF annotations?

Q:

I want to prevent the editing of PDF annotations. What are my options?

A:

One option is to disable annotation editing in the document’s security settings. PDF viewers which respect this flag will disable annotation editing if the flag is set. See the Encryption code samples (http://www.pdftron.com/pdfnet/samplecode.html#EncTest) as an example. Use the SecurityHandler::e_mod_annot flag.

Note that some viewers, including the PDFTron sample viewers, fail to respect this flag. Because PDFTron gives customers the source code to its viewer samples, you are free to customize annotation editing to respect the e_mod_annot flag.

However, there is another approach to disabling annotation editing that works in all viewers – simply merging annotations with page content. This can be done with PDFDoc.FlattenAnnotations().

Q: I used Preview application on Mac OS X to open some flattened PDFs and it is allowing me to fill in some form fields. I thought that PDFDoc.FlattenAnnotations() would remove all forms & annots?

Any idea what is going on?

A:

We looked into it and can confirm that PDF files flattened with PDFNet do not contain any information related to annotations of forms. The Preview is doing some monkey business to allow this sort of text editing. We tested this Preview ‘feaure’ on our end and found it to be buggy and unreliable.

There is technically nothing we (or you) can do to about this…. your clients can always temper with files (e.g. apply stamps, modify static content, etc.).

If you need to make sure that the original file is not modified, the right tool for the job would be to use electronic signatures (e.g. as shown in DigitalSignatures sample: http://www.pdftron.com/pdfnet/samplecode.html#Sig). With electronic signatures any modification to the file would invalidate the signature.

In case your main motivation is to enforce greater control over content (e.g. implement a custom DRM) you may want to take a look at WebViewer (http://www.pdftron.com/webviewer/index.html).

On Wednesday, November 27, 2013 12:44:42 PM UTC-8, Aaron Gravesdale wrote:

Q:

I want to prevent the editing of PDF annotations. What are my options?

A:

One option is to disable annotation editing in the document’s security settings. PDF viewers which respect this flag will disable annotation editing if the flag is set. See the Encryption code samples (http://www.pdftron.com/pdfnet/samplecode.html#EncTest) as an example. Use the SecurityHandler::e_mod_annot flag.

Note that some viewers, including the PDFTron sample viewers, fail to respect this flag. Because PDFTron gives customers the source code to its viewer samples, you are free to customize annotation editing to respect the e_mod_annot flag.

However, there is another approach to disabling annotation editing that works in all viewers – simply merging annotations with page content. This can be done with PDFDoc.FlattenAnnotations().