PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Pdf setting permissions
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4111
Page 1 of 1

Author:  Verthosa [ Thu Mar 12, 2020 10:27 am ]
Post subject:  Pdf setting permissions

i'm using PdfSharp 1.50.5147 and trying to set a restriction/permissions to not allow to print the document.

using (PdfDocument document = PdfReader.Open(output))
{
document.SecuritySettings.OwnerPassword = "xxxxxx";

// Printing
document.SecuritySettings.PermitPrint = permissions.First(x => x.Permission == Enums.PdfPermission.AllowPrinting).Allow;
document.SecuritySettings.PermitFullQualityPrint = permissions.First(x => x.Permission == Enums.PdfPermission.AllowPrinting).Allow;

// Change document
document.SecuritySettings.PermitModifyDocument = permissions.First(x => x.Permission == Enums.PdfPermission.AllowChangeDocument).Allow;

// Document assembly
document.SecuritySettings.PermitAssembleDocument = permissions.First(x => x.Permission == Enums.PdfPermission.AllowDocumentAssembly).Allow;

// Extract content
document.SecuritySettings.PermitExtractContent = permissions.First(x => x.Permission == Enums.PdfPermission.AllowContentCopying).Allow;

document.Save(output);
}
I'm totally sure that the SecuritySettings are set correct (false for PermitPrint and PermitFullQualityPrint, true for the rest) but still in the end when i open the document in Acrobat Reader the Assembly and Content Copying permission is also set to false (disallowed).

Am I missing something?

Author:  () => true [ Thu Mar 12, 2020 4:31 pm ]
Post subject:  Re: Pdf setting permissions

Already discussed on SO:
https://stackoverflow.com/q/60614867/162529

I don't think this is a bug in PDFsharp. PDFsharp can only follow the PDF Reference and set some configuration variables in the PDF.
What Adobe Reader makes with those values is beyond our control.

Do you see any descrepancies between PDFsharp and the PDF Reference?

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