I am wondering if I am doing something wrong. When I run the code below, the document seems to be secure, but when I open it on an iPad or Mac, it opens right up.
Public Shared Sub Encrypt(ByVal Filename As String, ByVal Password As String)
If String.IsNullOrEmpty(Filename) Then Exit Sub
Dim pdf As Integer
Try
Dim res As Integer = PDFToolsLib.PXCp_Init(pdf, PDFToolsLib.g_RegKey, PDFToolsLib.g_DevCode)
res = PDFToolsLib.PXCp_ReadDocumentW(pdf, Filename, 0)
PDFToolsLib.PXCp_EnableSecurityEx(pdf, 3, Password, "")
res = PDFToolsLib.PXCp_WriteDocumentW(pdf, Filename, PDFToolsLib.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
pdf = 0 'WriteDocument calls PXCp_Delete
Catch ex As Exception
msgbox "error"
End Try
If pdf <> 0 Then
PDFToolsLib.PXCp_Delete(pdf)
End If
End Sub
Secure Document
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
- Lzcat - Tracker Supp
- Site Admin
- Posts: 677
- Joined: Thu Jun 28, 2007 8:42 am
Re: Secure Document
A PDF file has two passwords - one for opening and the second for changing permissions. If either of them is blank - you can open PDF file without a password. Your trying to set an open password, but the permissions password is empty. You should do one of following:
1. Set both password to the same string
2. Set the Second password to anaother stringIn both cases you will be forced to specify passwords when opening the document, but there is important difference: in the first case you will be not able to override document security in most programs, but in the second you will be able to do this by specifying the Permissions Password when asked.
HTH.
1. Set both password to the same string
Code: Select all
PDFToolsLib.PXCp_EnableSecurityEx(pdf, 3, Password, Password)
Code: Select all
PDFToolsLib.PXCp_EnableSecurityEx(pdf,
3, Password, PermissionsPassword)
HTH.
Victor
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Secure Document
Just to make sure I am fulling understanding this, if I am just using your PDF-Viewer program, goto file menu, document properties and on the document properties dialog, select security, and password security. In the Passwords and Permissions dialog, where I am asked for a Password to open the document and a password to change permissions, and if I fill in only the password to open check box, then in effect the program calls
PDFToolsLib.PXCp_EnableSecurityEx(pdf, 3, Password, Password)
And sets the permissions password as well as the open password even though I didn't enter anything in the permissions password?
THanks for the help and sorry to ask for the clarification but as security is so important I really want to be sure I understand what I am doing.
PDFToolsLib.PXCp_EnableSecurityEx(pdf, 3, Password, Password)
And sets the permissions password as well as the open password even though I didn't enter anything in the permissions password?
THanks for the help and sorry to ask for the clarification but as security is so important I really want to be sure I understand what I am doing.
- John - Tracker Supp
- Site Admin
- Posts: 5219
- Joined: Tue Jun 29, 2004 10:34 am
- Location: United Kingdom
- Contact:
Re: Secure Document
Hi,
I believe Victor is saying it is the equivalent of - but it is not the same function - as the Viewer is an entirely different library set and is actually far more advanced in its underlying functionality and efficiency - the Viewer Library and design core methods will actually be what we base much of the new Version 5 PDF-Tools SDK code on (released later this summer) - although all our SDK's are being rewritten as we speak to actually consist of a single library set with varying layers so information/files/streams etc can be passed from what were previously separate products and libraries far more easily (and in some cases not at all) than now ...
HT
I believe Victor is saying it is the equivalent of - but it is not the same function - as the Viewer is an entirely different library set and is actually far more advanced in its underlying functionality and efficiency - the Viewer Library and design core methods will actually be what we base much of the new Version 5 PDF-Tools SDK code on (released later this summer) - although all our SDK's are being rewritten as we speak to actually consist of a single library set with varying layers so information/files/streams etc can be passed from what were previously separate products and libraries far more easily (and in some cases not at all) than now ...
HT
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
- Lzcat - Tracker Supp
- Site Admin
- Posts: 677
- Joined: Thu Jun 28, 2007 8:42 am
Re: Secure Document
Yes, this assumption is correct. Adobe products use same way, and many others too.tdonovan wrote:Just to make sure I am fulling understanding this, if I am just using your PDF-Viewer program, goto file menu, document properties and on the document properties dialog, select security, and password security. In the Passwords and Permissions dialog, where I am asked for a Password to open the document and a password to change permissions, and if I fill in only the password to open check box, then in effect the program calls
PDFToolsLib.PXCp_EnableSecurityEx(pdf, 3, Password, Password)
And sets the permissions password as well as the open password even though I didn't enter anything in the permissions password?
Victor
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.