Lock pdf without password


#1

we need to prevent a pdf (converted from .docx) from being edited and printed, but we don’t want it to be password protected.
is it possible ?


#2

@tparassin

You can use following code example to achieve your requirement. Hope this helps you.

Document doc = new Document(MyDir + "Rendering.doc");

PdfSaveOptions saveOptions = new PdfSaveOptions();

// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails =
    new PdfEncryptionDetails("password", string.Empty, PdfEncryptionAlgorithm.RC4_128);

// Start by disallowing all permissions.
encryptionDetails.Permissions = PdfPermissions.DisallowAll;

saveOptions.EncryptionDetails = encryptionDetails;

// Render the document to PDF format with the specified permissions.
doc.Save(ArtifactsDir + "Rendering.SpecifyPermissions.pdf", saveOptions);