PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

pdfsharp document security
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1442
Page 1 of 1

Author:  sarad1978 [ Fri Nov 26, 2010 3:50 pm ]
Post subject:  pdfsharp document security

I was wondering if there was a way to protect the document built using PDFSharp from editing but not require a password to open it. I see the security sample in the documentation and it totally works for me, but i'd have to enter the password each time.

Thanks in advance for any help.

Author:  Thomas Hoevel [ Mon Nov 29, 2010 11:10 am ]
Post subject:  Re: pdfsharp document security

Yes, can be done.
I'll have to look up the details.

Author:  Thomas Hoevel [ Mon Nov 29, 2010 12:37 pm ]
Post subject:  Re: pdfsharp document security

The "trick" is setting an OwnerPassword but no UserPassword.

Here's a code snippet for a PdfDocument document:
Code:
document.SecuritySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted128Bit;
document.SecuritySettings.OwnerPassword = Guid.NewGuid().ToString();
document.SecuritySettings.PermitModifyDocument = false;
document.SecuritySettings.PermitExtractContent = false;
document.SecuritySettings.PermitAnnotations = false;
document.SecuritySettings.PermitAssembleDocument = false;
document.SecuritySettings.PermitFormsFill = false;

Author:  sarad1978 [ Tue Nov 30, 2010 7:47 pm ]
Post subject:  Re: pdfsharp document security

Excellant! Thanks so much :D
your suggested worked.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/