- We try to Encrypt pdf file (attached - it looks ok, every browsers can open it) by this code
- Code: Select all
using (var stream = new FileStream(@"C:\Work\Errors\Wrong ecrypted Pdf\source_can_be_opened.pdf", FileMode.Open))
{
var pdf = new PdfDocument(stream);
pdf.Security.Encrypt(
"037789",
"037789",
PdfPermissionsFlags.Print | PdfPermissionsFlags.CopyContent,
PdfEncryptionKeySize.Key128Bit);
pdf.SaveToFile(@"C:\Work\Errors\Wrong ecrypted Pdf\encrypted_can_not_be_opened.pdf", FileFormat.PDF);
}
Result file is corrupted and can't be even opened. Edge want to set password and next show info "File corrupted". Adobe reader show error 118 (Unexpected token) without password prompt.
Best regards
Dariusz Arendarski