How to make a PDF non-editable

Q: Is there a good way to make a PDF file non-editable?

A: There are some options here:

  1. If you want to disable interaction within your app you can prevent to user to interact with the PDF. For example, with the Android PDFNet SDK you can use PDFViewCtrl.setInteractionEnabled(false). This will avoid users to enter new annotations or editing forms.
  2. There are security flags that other viewers besides ours honor; we let people edit these but don’t observe them ourselves: http://www.pdftron.com/pdfnet/intro.html#pdfdocsecurity
  3. Alternatively, you can flatten the content. You could use flatten annotations: https://groups.google.com/d/msg/pdfnet-sdk/qimJ1VPVPqI/710n_qv_p8EJ

Note that each application may or may not honor the security flags. Also, opening a flattened document in other viewers will not prevent them to add new content to the document.

For option 1 - can users still view all previous annotations and then scroll, zoom etc?

Yes, by default all the annotations are visible.

You can hide all annotations with PDFViewCtrl.setDrawAnnotations(false)
https://www.pdftron.com/pdfnet/mobile/docs/Android/pdfnet/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#setDrawAnnotations(boolean)

Or you can hide individual ones with PDFViewCtrl.hideAnnotation
https://www.pdftron.com/pdfnet/mobile/docs/Android/pdfnet/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#hideAnnotation(com.pdftron.pdf.Annot)