I am using ReportingEngine to generate pdf files, but I wnat to make them read only (copy + paste functions disable). I used the following code, but it doesn’t work :
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, myData, “data”);
doc.Protect(ProtectionType.ReadOnly);
doc.Save(outputFile);
Thanks for your inquiry. Please use PdfSaveOptions.EncryptionDetails property as shown below to set the detail for encrypting the output PDF document. Hope this helps you.
Document doc = new Document(MyDir + "input.docx");
//Your code...
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(String.Empty, "password", 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(MyDir + "18.11.pdf", saveOptions);