Secure Document

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
tdonovan
User
Posts: 61
Joined: Tue Jun 12, 2007 9:21 pm

Secure Document

Post by tdonovan »

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
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Secure Document

Post by Lzcat - Tracker Supp »

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

Code: Select all

PDFToolsLib.PXCp_EnableSecurityEx(pdf, 3, Password, Password)
2. Set the Second password to anaother string

Code: Select all

PDFToolsLib.PXCp_EnableSecurityEx(pdf, 

3, Password, PermissionsPassword)
In 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.
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.
tdonovan
User
Posts: 61
Joined: Tue Jun 12, 2007 9:21 pm

Re: Secure Document

Post by tdonovan »

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.
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Secure Document

Post by John - Tracker Supp »

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
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
tdonovan
User
Posts: 61
Joined: Tue Jun 12, 2007 9:21 pm

Re: Secure Document

Post by tdonovan »

Thanks.
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Secure Document

Post by Lzcat - Tracker Supp »

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?
Yes, this assumption is correct. Adobe products use same way, and many others too.
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.
Post Reply