We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF security without signing

Hi,
I want to create a PDF file using Aspose.PDF .Net.
I do NOT want to sign the file (digital or electronic signature) but I want
1 : to give alert if file is tampered
2 : to secure it against any change in file contents.

Is this possible?
If yes, How?

Thanks.

Mukund.

@MukundGadre

You can convert the pages to images and create a PDF file containing those images. You can check Convert PDF document article for details.

Dear Mr. Mudassir,

I appreciate your prompt response and thanks for that.

Actually, converting contents in image and then back to PDF file will not allow user to copy selected part of the file. I want my user to be able to selectively copy from my file but the user should not be able to modify the content.

I was thinking of encrypting the file using “Owner” password but not using “User” Password.

Will this help?

Do you foresee any problem in this procedure?

Please guide.

image001.jpg (169 Bytes)

@MukundGadre

Please try the following code which restricts all permissions and encrypts with the owner password. Let us know if this satisfies your requirements.

Document doc = new Document(dataDir + "Sample.PDF");
SaveOptions option = new PdfSaveOptions();
Permissions Permission = new Permissions();
string password = string.Empty;
Permission = Permissions.PrintDocument;
doc.Encrypt(password, null, Permission, CryptoAlgorithm.AESx128);
doc.Save(dataDir + "Secured.PDF", option);

Thanks Mr. Mudassir for your suggestions.

I am trying the code whether it is up to the required level of locking.

In the meantime, I could find that the line

image001.jpg (169 Bytes)

@MukundGadre

Can you please explin this query a little more?

If you pass null in place of password, execution time you get exception. So you have to pass ”" as password parameter.

1 : If you pass null as parameter in place of password, there is run time error “Unassigned object value”. So we have to pass empty string (.e. “”) in place of password.

2 : Also the user password should be “” and the owners password should be a valid authentic password.

image001.jpg (169 Bytes)

image002.jpg (163 Bytes)

@MukundGadre

I am afraid your image attachments are not valid so I request you to attach to forum thread instead of replying via email so that we can address the problem. Please share if suggested approach satisfies your requirements or not?

, I could find that the line

doc.Encrypt(password, null, Permission, CryptoAlgorithm.AESx128);


won’t accept null as parameter and passing “” (empty string) can be accepted by runtime.

Also, the password should be passed as owners password. (second parameter instead of first parameter).

1 : If you pass null as parameter in place of password, there is run time error “Unassigned object value”. So we have to pass empty string (i.e. “”) in place of password.

2 : Also the user password should be “” and the owners password should be a valid authentic password.

@MukundGadre

You can adjust it as under and share your feedback.

doc.Encrypt(password, "password", Permission, CryptoAlgorithm.AESx128);

As mentioned in my pervious communication, it works well if I pass empty string for user password and actual password for owners password parameter.

Thanks for your support.

@MukundGadre

It’s good to know that suggested option has proved to be working on your end.