How to unencrypt a document before merging?

PDF-XChange Editor SDK for Developers

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

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Posts: 499
Joined: Thu Dec 06, 2007 8:13 pm

How to unencrypt a document before merging?

Post by docu-track99 » Mon Nov 13, 2017 5:59 pm


This is an urgent matter for us as a client needs to lock down their software for tax season.

For merging PDFs we have switched from the old Tracker tools library to the new Tracker Editor Core. We have found that the new Core functionality is superior in almost every case.

Our issue with the new core is if a file to be merged in has encryption in it. (Not open document security, but security to edit, etc.)

In our old way of merging using the tool Library we would do something like example A below.

In our new way of doing it (Example B), we can’t figure out how to unencrypt the document before merging.

The Op.Do method is throwing an error: “Insert Pages Document: <Full path to PDF> is protected. You have no permissions to use it for this operation. Ignore Ignore All Abort.”

The attached file works in the old method but not in the new. We had switched to the new method because it is much more successful in working with large files.

Example A:

If nDocCount >= 1 Then
oDocITPDFOutput = New PDFClasses.cDocITPDFExisting

For nIdx = 0 To nDocCount - 1
frmMain.AddLogEntry(" Merging " & System.IO.Path.GetFileName(sPdfPaths(nIdx)))

If bFirstFile Then
With oDocITPDFOutput
nDocPages = .PageCount
If .Encrypted Then
nRet = .Unencrypt
End If
nOutline = oDocITPDFOutput.GetFirstOutline()
bFirstFile = False
End With
oDocITPDFInput = New PDFClasses.cDocITPDFExisting
With oDocITPDFInput
nMergeDocID = .SelectedDocument
nDocPages = .PageCount
If .Encrypted Then
nRet = .Unencrypt
End If
nOutline = oDocITPDFInput.GetFirstOutline()
nRet = oDocITPDFOutput.MergeDocument(nMergeDocID, -1)
End With
oDocITPDFInput = Nothing
End If

Example B:

Dim m_Inst As PDFXEdit.PXV_Inst = Nothing
m_Inst = New PDFXEdit.PXV_Inst()
m_Inst.Init(Nothing, "licence key”)
Dim fsInst As PDFXEdit.IAFS_Inst = CType(m_Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)

Dim nID As Integer = m_Inst.Str2ID("op.combineDocs", False)
Dim Op As PDFXEdit.IOperation = m_Inst.CreateOp(nID)
'This operation has quite a unique input that uses IOpInputItem
Dim input As PDFXEdit.ICabNode = Op.Params.Root("Input")
Dim destPath As PDFXEdit.IAFS_Name
Dim inpItem As PDFXEdit.IOpInputItem

For nIdx = 1 To nDocCount
frmMain.AddLogEntry(" Adding " & System.IO.Path.GetFileName(sPdfPaths(nIdx)) & " to list of files to merge.")
destPath = fsInst.DefaultFileSys.StringToName(sPdfPaths(nIdx))
inpItem = Op.CreateInputItem(destPath)
inpItem.Params.Root("PagesRange.Type").v = "All"
input.Add().v = inpItem

Dim options As PDFXEdit.ICabNode = Op.Params.Root("Options")
options("AddRootBookmarks").v = False

'Perform actual merge.
frmMain.AddLogEntry(" Merging beginning")

'Getting resulting document
Dim resDoc As PDFXEdit.IPXC_Document = DirectCast(Op.Params.Root("Output").v, PDFXEdit.IPXC_Document)

[attachment=0]Security Info.png[/attachment]
Security Info.png
(31.27 KiB) Downloaded 34 times

User avatar
Sasha - Tracker Dev Team
Posts: 4862
Joined: Fri Nov 21, 2014 8:27 am

Re: How to unencrypt a document before merging?

Post by Sasha - Tracker Dev Team » Mon Nov 13, 2017 6:31 pm

Hello docu-track99,

The way to specify the documents' passwords is to open them before passing to the operation. Then if the password is correct, the operation will use the opened document and won't ask for the password. I think this should work if I understood you correctly.

Join us at Google+:
Subscribe at:

Posts: 499
Joined: Thu Dec 06, 2007 8:13 pm

Re: How to unencrypt a document before merging?

Post by docu-track99 » Mon Nov 13, 2017 6:48 pm

Hi Alex,

There is not a password required to open this document, but rather to perform operations on the document

In our old method we were not supplying the password but could do an unecrypt on the in memory object without it. (As shown in example A.)

Example B came originally from Tracker, but do not know how to do this opening an unecryption with the new API and example B.

Could you suggest sample code that we could try? Keep in mind that this is a merge operation that is being performed and we are not loading any of the files into the editor.

Posts: 499
Joined: Thu Dec 06, 2007 8:13 pm

Re: How to unencrypt a document before merging?

Post by docu-track99 » Mon Nov 13, 2017 9:46 pm

We would like to emphasize the urgency of this.

With the old Tracker Tools SDK you can merge two files without providing a password. (The file has an operations level password, but not an open password.) With the new editor library we can not figure out how to do this.

Note that if you use the pdf file that we attached earlier today and try and merge it with another PDF in your new tracker editor, it throws an error.

Please get back to us as soon as possible so we can implement a solution or work around.

Lzcat - Tracker Supp
Site Admin
Posts: 719
Joined: Thu Jun 28, 2007 8:42 am

Re: How to unencrypt a document before merging?

Post by Lzcat - Tracker Supp » Tue Nov 14, 2017 6:46 am

Hi docu-track99.
There was a bug in old SDK which will allow you to do everything you want even your password does not grant needed permissions, and you have successfully used it. We fixed this in new SDK, and all we can offer at the moment is a way to ask for owner (change permissions) password.
To do this you will need to call IPXC_Document::RequestPermission(Perm_ObjDoc, Perm_OperSecure, null, status) to check if you have needed permissions, and if not - call IPXC_Document::AcquireOwnerPermissions.
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