Betsy.jiang wrote:Hi,
Thanks for your inquiry.
Firstly, I noticed you were using old Spire.PDF, as the method pdf.Security.OwnerPassword is obsolete in the latest
Spire.PDF Pack(Hot Fix) Version:5.1.33. Please download it and use the new code doc.Security.Encrypt() to encrypt your PDF.
Besides, did you mean the result file would be opened correctly without open password in Adobe Reader yet just the PDF-Exchange viewer has the issue ? If so, I am afraid the issue is related to PDF-Exchange viewer. Since our product is based on Adobe, and there is no issue with Adobe reader.
Sincerely,
Betsy
E-iceblue support team
Hi, I upgraded to the last version and i change my code:
- Code: Select all
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SetRightUserDocument("doc2.pdf", "test", PdfPermissionsFlags.Print Or PdfPermissionsFlags.FullQualityPrint)
End Sub
Public Function SetRightUserDocument(ByVal pdfFile As String, ByVal password As String, ByVal PermissionstUserFlags As PdfPermissionsFlags) As Boolean
Try
Dim pdf As New PdfDocument()
pdf.LoadFromFile(pdfFile)
pdf.Security.Encrypt("", password, PermissionstUserFlags, PdfEncryptionKeySize.Key256Bit)
pdf.SaveToFile(pdfFile)
Return True
Catch ex As Exception
Return False
End Try
End Function
but when i open my document with PDF-Echange Viewver, i have an dialogbox for entered password.
I type "test" 3 times and i have an error :
Error [PDF Structure 40] : Wrong Password
But run perfect with Adobe Reader.
Thank you