Create PDF with Locked annotations (non-editable without password)

178 views
Skip to first unread message

Chris at Newforma

unread,
Jan 4, 2015, 3:22:59 PM1/4/15
to pdfne...@googlegroups.com
Hey guys,

I know it's possible to create a PDF with annotations on it that can't be edited without knowing a password. How would one accomplish that using PDFNet? We have the annotations writing out, and they are locked by default. However, you can simply turn off the lock in Acrobat without any special password or anything.

Thanks - Chris

Ryan

unread,
Jan 5, 2015, 7:34:31 PM1/5/15
to pdfne...@googlegroups.com
If you look at the EncryptionTest sample code, you can see how to add a password to a PDF, and also how to specify the permissions, such as annotation editing, using StdSecurityHandler.SetPermission method.

https://www.pdftron.com/pdfnet/samplecode.html#EncTest

http://www.pdftron.com/pdfnet/docs/PDFNet/?topic=html/M_pdftron_SDF_StdSecurityHandler_SetPermission.htm

You can also set flags directly on specific annotations, though this would have less "security" then the above way. Some of the these flags specify ReadOnly for instance.
http://www.pdftron.com/pdfnet/docs/PDFNet/?topic=html/T_pdftron_PDF_Annot_Flag.htm

Chris at Newforma

unread,
Jan 6, 2015, 11:33:56 AM1/6/15
to pdfne...@googlegroups.com
Thanks Ryan! I'll take a look at that.

I appreciate the help!

- Chris

Support

unread,
Jan 6, 2015, 2:03:39 PM1/6/15
to pdfne...@googlegroups.com

Note that PDF security is based on 'trust' model your users will always be able to go around permissions (if they really want to).

Another option (that is a bit harder to tamper with) would be to flatten annotations by merging them to PDF content stream (e.g. annot.Flatten(page) or doc.FlattenAnnotations()). 

Chris at Newforma

unread,
Jan 6, 2015, 2:32:52 PM1/6/15
to pdfne...@googlegroups.com
If we were to merge them to a content stream, is there any way to still maintain the metadata?

Ryan

unread,
Jan 6, 2015, 3:45:23 PM1/6/15
to pdfne...@googlegroups.com
By Metadata I assume you mean annotation related information, such as author, last modified date, etc?

That stuff all gets erased when flattening, but you can store it in the PDF before flattening so it is not lost, but it would become hidden data that only you know about, and would no longer be tied to the appearance of the annotation.

To store arbitrary data in a PDF see the following.
https://groups.google.com/forum/?fromgroups#!searchin/pdfnet-sdk/custom$20data/pdfnet-sdk/gtPjLZVbRSQ/Tv5DTb9pRXkJ

Reply all
Reply to author
Forward
0 new messages