Initial file locked after Op.Do combine

PDF-XChange Editor SDK for Developers

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

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
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Initial file locked after Op.Do combine

Post by docu-track99 »

Hi Tracker,

I use the following code to combine multiple files into a single pdf. Once the operation is complete I need to delete the temporary working files. My first input file, in this case "IndexPage.pdf" remains locked until after I close my program. I have been able to verify that it is not locked before I execute the op.Do command, and remains locked from that point onwards.

Any suggestions as to what I should be doing to unlock it? My code is below.

Thanks!



Dim m_Inst As PDFXEdit.PXV_Inst = Nothing
m_Inst = New PDFXEdit.PXV_Inst()
m_Inst.Init(Nothing, GetTrackerLicenseKey)

Dim fsInst As PDFXEdit.IAFS_Inst = CType(m_Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)


destPath = fsInst.DefaultFileSys.StringToName(sTempSettingsPath & "\IndexPage.pdf")
inpItem = Op.CreateInputItem(destPath)
inpItem.Params.Root("PagesRange.Type").v = "All"
input.Add().v = inpItem

inpItem = Nothing

'Add other files to list to be merged.
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
inpItem = Nothing
Next


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

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

Op.Do()

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

resDoc.WriteToFile(sOutputPath)


Op = Nothing
fsInst = Nothing
m_Inst = Nothing
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Initial file locked after Op.Do combine

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

This is a known problem - the document itself is not being closed - thus this behaves like this. You can fix this by opening the document, passing it to the operation and then closing it - this should behave correctly then.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

So in my example above, what would that look like code wise. I ask, because I had a heck of a time trying to get my code to work initially from your examples.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Initial file locked after Op.Do combine

Post by Sasha - Tracker Dev Team »

This piece of code:

Code: Select all

destPath = fsInst.DefaultFileSys.StringToName(sTempSettingsPath & "\IndexPage.pdf")
inpItem = Op.CreateInputItem(destPath)
Should be modified to opening the IPXC_Document from path and then doing the CreateInputItem with it.
After doing the operation you should call the Doc.Close() method to the document that you have passed into the input.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

You didn't answer my question.

I know where I have to make the change in my code. What is YOUR code method to load a file from a path.

From the list of methods for IPXC_Document it is not at all clear.

I have:

Dim Doc As PDFXEdit.IPXC_Document

How do I load my document into Doc from a path.
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

Still waiting for a response:

If I have code like the following:

Dim Doc As PDFXEdit.IPXC_Document

How do a load a document from a path using the core api?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Initial file locked after Op.Do combine

Post by Sasha - Tracker Dev Team »

Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

Thank you. I can work from this.

I do find in general that Tracker could do much better in providing examples of how to use your inface.
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

I want to cancel my last remarks.

I asked for an example. You gave me a link to the interface. Is it that hard to provide an example of how you would use this interface in code???

I gave you my sample code. Please provide a concrete example for me. I am really tired of the run around.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Initial file locked after Op.Do combine

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

There were plenty of topics with the OpenDocumentFromFile methods that can be easily find with the forum search. For example:
viewtopic.php?f=66&t=27275&p=105804#p105804
Also, where are you experiencing a problem exactly? This is a simple method that consist only from one string by default and does not require anything except the IPXC_Inst that can be easily obtained from the IPXV_Inst via the GetExtension("PXC") method.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

"This is a simple method that consist only from one string by default and does not require anything except the IPXC_Inst that can be easily obtained from the IPXV_Inst via the GetExtension("PXC") method."

I have no idea what you mean by that.

Here is where I am now at. Having looked at all the examples that all the others users have posted I see that they are doing some version of:


Public Class AuthCallback
Implements PDFXEdit.IPXC_DocAuthCallback
Public Sub AuthDoc(ByVal pDoc As PDFXEdit.IPXC_Document, ByVal nFlags As UInteger) Implements PDFXEdit.IPXC_DocAuthCallback.AuthDoc
'Will hit this method if password is required.
End Sub
End Class
.
.
.
Dim m_pxcInst As PDFXEdit.IPXC_Inst = Nothing
Dim Doc As PDFXEdit.IPXC_Document
Dim clbk As AuthCallback = New AuthCallback()
.
.
.
Doc = m_pxcInst.OpenDocumentFromFile(mypath, clbk)

My code fails on this last line with a "Object reference not set to an instance of an object". Mypath has been properly set. [b] What am I missing here?[/b] Very, very frustrated on having to spend hours on something that should take a few minutes.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Initial file locked after Op.Do combine

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

Well, from your code, I don't see where you are initializing the m_pxcInst - you are using the null value thus the error occurs.
What you need to do is to use the (IPXC_Inst)GetExtension('PXC') method of the IPXV_Inst:

Code: Select all

pxcInst = (PDFXEdit.IPXC_Inst)pdfCtl.Inst.GetExtension("PXC");
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Initial file locked after Op.Do combine

Post by docu-track99 »

Ah, I finally realise our disconnect. When we started this whole merge process a year ago, we were doing a merge using the Core of the SDK. We do not use an instance of the pdfctrl. That is why you originally told me to use code that looked like this:

destPath = fsInst.DefaultFileSys.StringToName(sTempSettingsPath & "\IndexPage.pdf")
inpItem = Op.CreateInputItem(destPath)

The line you just posted uses the pdfctrl which we are not using in our code here as it has no UI..
Is there any way to resolve this problem without using the pdfctrl?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Initial file locked after Op.Do combine

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

Well, if you just have the IPXV_Inst available, then the code would change to:

Code: Select all

pxcInst = (PDFXEdit.IPXC_Inst)pxvInst.GetExtension("PXC");
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply