Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Mar 24, 2022 3:19 pm

PdfDocument doc = new PdfDocument();
string sFileAtt = Server.MapPath("./dati/" + xxxx);
doc.LoadFromFile(sFileAtt);
PdfEncryptionKeySize keySize = PdfEncryptionKeySize.Key256Bit;
string openPassword = "";
string permissionPassword = "XXXX";
PdfPermissionsFlags flags = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields;
doc.Security.Encrypt(openPassword, permissionPassword, flags, keySize);
doc.SaveToFile(“yyyyy”);


The saved file has no attachments!
Attached is an example before and after

silvano.laboranti
 
Posts: 4
Joined: Thu May 24, 2018 7:44 am

Fri Mar 25, 2022 3:30 am

Hello,

Thanks for your inquiry.
We received your email about this issue on March 23, 2022, and made the following reply in the email I sent you on March 23, 2022:
I didn’t reproduced the scenario while I used the latest version of Spire.PDF (Spire.PDF Pack(Hot Fix) Version:8.3.9) and the code you provided to encrypt the Example.pdf. If you’re not using this version, please download it and have a test. However, if you have any issues after test, please provide the information below. In addition, I put my test code below and attached the test result document. Thanks for your assistance in advance.

1) The .Net Framework version of your project, such as .net4.0.
2) Your system environment ( (E.g. Windows 10,64-bit) and region setting(E.g. China, Chinese) ).

My test code:

Code: Select all
 PdfDocument doc = new PdfDocument();
            string sFileAtt = "G:/Example.pdf";
            doc.LoadFromFile(sFileAtt);
            PdfEncryptionKeySize keySize = PdfEncryptionKeySize.Key256Bit;
            string openPassword = "123456";
            string permissionPassword = "123456789";
            PdfPermissionsFlags flags = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields;
            doc.Security.Encrypt(openPassword, permissionPassword, flags, keySize);
            doc.SaveToFile("G:/Example-result.pdf");

Sincerely,
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Fri Mar 25, 2022 9:43 am

But was the example written in a web form?
Because on console I had no problems on protection.
Thanks

silvano.laboranti
 
Posts: 4
Joined: Thu May 24, 2018 7:44 am

Fri Mar 25, 2022 10:24 am

Hello silvano,

I created a Web project to do a test but didn't reproduce your problem. Please provide your Web project to help us reproduce your issue and work out a solution for you. Thank you for your assistance in advance.

Sincerely,
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Sat Apr 02, 2022 10:18 am

Hello Silvano,

Hope you are doing well.
Have you solved your issue? If it hasn’t been solved, please provide us with your Web project to help us reproduce your issue and work out a solution for you. Thank you for your assistance in advance.

Sincerely,
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Fri Apr 08, 2022 10:36 am

Hello Silvano,

Hope you are doing well.
Could you please let us know how is the issue going? Thanks in advance for your feedback and time.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc

cron