Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Feb 05, 2019 8:05 pm

I, i use this fonction to protect my pdf. This code run perfect with acrobat reader, but with PDF-Exchange viewver a dialog appear and ask me a password to open the doc. But if I'm not mistaken, the "Owner" password allows you not to set a password when you open the document. What's wrong?

Code: Select all
Public Function SetRightUserDocument(ByVal pdfFile As String, ByVal password As String) As Boolean
        Try
            Dim pdf As New PdfDocument()
            pdf.LoadFromFile(pdfFile)
            'set encryption level
            pdf.Security.KeySize = PdfEncryptionKeySize.Key256Bit
            'set all restrictions as Not Allowed
            pdf.Security.OwnerPassword = password
            'enable the permissions of Printing and Copying
            pdf.Security.Permissions = PdfPermissionsFlags.Print Or PdfPermissionsFlags.FullQualityPrint
            pdf.SaveToFile(pdfFile)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

STEPH91
 
Posts: 6
Joined: Mon Nov 05, 2018 7:23 pm

Wed Feb 06, 2019 3:26 am

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
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Feb 06, 2019 5:23 pm

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

STEPH91
 
Posts: 6
Joined: Mon Nov 05, 2018 7:23 pm

Thu Feb 07, 2019 5:13 am

Hello,

Thanks for your feedback.
Like my colleague Betsy previous replied, our Spire.PDF is based on Adobe, but there is no issue with Adobe reader. This issue should be related to PDF-Exchange viewer itself. Anyway, we will post it to our Dev team for a further review, if there is any update, we will let you know.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Thu Feb 07, 2019 12:04 pm

Lisa.Li wrote:Hello,

Thanks for your feedback.
Like my colleague Betsy previous replied, our Spire.PDF is based on Adobe, but there is no issue with Adobe reader. This issue should be related to PDF-Exchange viewer itself. Anyway, we will post it to our Dev team for a further review, if there is any update, we will let you know.

Sincerely,
Lisa
E-iceblue support team



Thank you

STEPH91
 
Posts: 6
Joined: Mon Nov 05, 2018 7:23 pm

Tue Feb 22, 2022 10:26 am

Hello,

Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:8.2.2 which fixed the reported issue, please download it from the following links to test.
Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/8.2.2

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF