cmd.newDocCombine options

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
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

cmd.newDocCombine options

Post by jusWest »

Hello!

We are using cmd.newDocCombine to open the dialog for combining multiple pdf files into one. This works great.

Now, if I want to prefill the file list in this dialog for some semi automation, is that possible?

say I have a path sent trough commandline options, is there a way to tell this dialog to use this path and fill
the list with the files in that path without user interaction?

regars
Ronny
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

Hello jusWest,

There is a way of doing that. You can pass the needed files into the "Input" cab node of the operation as a IAFS_File or IAFS_Name elements. Then when the dialog is shown then the files will be added.
You should intercept the operation via catching the https://sdkhelp.pdf-xchange.com/vi ... oreExecute event and checking whether it's a https://sdkhelp.pdf-xchange.com/vi ... ombineDocs operation. You can search the forums for this event.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

Thanks for the answer.

The e.operBeforeExecute event fires when i press ok in the combine dialog, not before the dialog is shown.

I'm able to catch it like this

Code: Select all

if (oper.ID == _editorView.pdfctl.Inst.Str2ID("op.combineDocs"))
but as I said, to late to fill the dialog.

am I understanding you correctly here?

AND
You can pass the needed files into the "Input" cab node of the operation as a IAFS_File or IAFS_Name elements.
Any examples of this?
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: cmd.newDocCombine options

Post by zarkogajic »

Hi,
Now, if I want to prefill the file list in this dialog for some semi automation, is that possible?
Would you still allow users to *not* select some of the pre-filled ones ? Or pre-filled for you means they must be a part of the combining process (and the user can select some more of those that are not pre-filled)?

-žarko
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

zarkogajic wrote: Mon May 11, 2020 11:49 am Hi,
Now, if I want to prefill the file list in this dialog for some semi automation, is that possible?
Would you still allow users to *not* select some of the pre-filled ones ? Or pre-filled for you means they must be a part of the combining process (and the user can select some more of those that are not pre-filled)?

-žarko
Prefilled for me, means that we have a list of files that wil be sent to the dialog box, so that the file list has theese filenames. Then they(users) can also add/delete more files, or using all other functionality of the dialog.

Does that make sense to you?
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: cmd.newDocCombine options

Post by zarkogajic »

Hi,

If that means they can decide to remove (in open dialog) any of pre-filled ones - sorry I cannot help with that ...


-žarko (not a support member)
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

I checked the spec again. It does not say if they should be able to delete some of the prefilled ones, but they need to be able to add more files.
If that means they can decide to remove (in open dialog) any of pre-filled ones - sorry I cannot help with that ...
What solution did you have in mind if they was not allowed to delete?
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: cmd.newDocCombine options

Post by zarkogajic »

Hi,

So, if you have a fixed set of files and then allow to add some more (via Open dialog), this part:
You can pass the needed files into the "Input" cab node of the operation as a IAFS_File or IAFS_Name elements.
Catch the e.operBeforeExecute in OnEvent, then (using pseudo code):

1. when nEventID = e.operBeforeExecute
2. op = IOperation(pFrom);
3. if op = op.combineDocs then
3.1. for each filename in pre-filled files do: op.Params.Root['Input'].Add(dt_IUnknown).v = iafsName(filename)

Where iafsName(filename) is IAFS_Inst.DefaultFileSys.StringToName(filename, 0, null);

This way you add more "hard-coded" files to the op.combineDocs operation before it gets executed.

p.s.
If they can select, via Open dialog, a file in your "hidden" pre-fillled list, make sure to have an "if not already in" in step [3.1] as you might add a file two times (and maybe you do not want that).

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

Thanks for the assistance žarko :)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

Thanks zarko :)


Sasha!

Zarkos solution might work for us.

But was this the kind of solution you suggested? Does this mean that there is no way of prefilling the visual filelist of the dialog?

/Ronny
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

Hello jusWest,

Well žarko did use my solution - as I described previously, you should catch the e.operBeforeExecute, fill the "Input" CAB node with the needed files/names and then continue the operation execution. When the operation calls the ShowSetupUI method, that shows the dialog, it tries to read the files from the Input node (empty by default) - if there are items available there, they will be used and displayed in the files list of the dialog.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

ahh, ok, off to try this then :)

Thanks!

/Ronny
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

So, got a test somehow working.

I test using this code:

Code: Select all

private void e_operBeforeExecute(object sender, _IPXV_ControlEvents_OnEventEvent e)
{
	IOperation op = (IOperation)e.pFrom;

	//// catch the op.combineDocs opreation
	if (op.ID == _editorView.pdfctl.Inst.Str2ID("op.combineDocs"))
	{

		IAFS_Inst fsInst = _editorView.pdfctl.Inst.GetExtension("AFS");

		var testfile1 = fsInst.DefaultFileSys.StringToName(@"test1.pdf", 0, null);
		var testfile2 = fsInst.DefaultFileSys.StringToName(@"test2.pdf", 0, null);

		op.Params.Root["Input"].Add(CabDataTypeID.dt_IUnknown).v = testfile1;
		op.Params.Root["Input"].Add(CabDataTypeID.dt_IUnknown).v = testfile2;
	}
}
But this only gets added after I click the OK button in the dialog, The file list in the dialoig is empty
when I open it, and I need to add an extra file to enable the ok button.
combine.PNG
When this is done, and I press ok, the tree files are combined, so the cabnode gets the filenames, but only after I press ok.

Am I doing something wrong?

/Ronny
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

Sasha - Tracker Dev Team wrote: Tue May 12, 2020 7:12 am Hello jusWest,

Well žarko did use my solution - as I described previously, you should catch the e.operBeforeExecute, fill the "Input" CAB node with the needed files/names and then continue the operation execution. When the operation calls the ShowSetupUI method, that shows the dialog, it tries to read the files from the Input node (empty by default) - if there are items available there, they will be used and displayed in the files list of the dialog.

Cheers,
Alex
Based on what you are saying here Alex, this behaviour is not what I am seeing. So I must be missunderstanding something??
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

Hello jusWest,

My mistake here - the dialog shows before the event is fired. And even if you have the event monitor on the e_ShowModal, you won't be able to get to the operation that called that dialog with the ShowSetupUI method.
What you can do though is call the dialog's List object's List_OnDrop method with prefilled pFmtEtc as CF_HDROP and pStdMed with file list. Also, do not forget to set the nEffect to DragDropEffects.Copy and pDropPos to some existing position (for example 0,0).
Here's how you can get the needed dialog and it's objects (List is what you need - it has the ID of "bnf.Lst.Files"). After you cast it to the IUIX_List interface you should be able to call the List_OnDrop method.
The FmtEtc and StgMed are standard Winapi classes/structures that are being used for Drag and Drop :

Code: Select all

System.Runtime.InteropServices.ComTypes.FORMATETC
System.Runtime.InteropServices.ComTypes.STGMEDIUM
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: cmd.newDocCombine options

Post by jusWest »

Thanks for your answer.

I'm not sure I follow, are you saing that i should fake a drag drop situation?

As this dialog handling i somewhat new to me, do you have a simple example of using List_OnDrop ?

/Ronny
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

Hello jusWest,

Yes - the way to do this logic is to fake the drop into the dialog.
There are no samples of the List_OnDrop method as you don't direct usage of it as it is a callback method.
You need to call it with prefilled drop data - that would do the trick. You can google how to fill the STGMEDIUM data for your language - I have told you every parameter that's left.
You should start by catching the dialog and then casting the object interface to IUIX_List - after that, you can search for STGMEDIUM usage.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: cmd.newDocCombine options

Post by zarkogajic »

Hi Alex,

Out of curiosity: what is the ID of that dialog? (cannot find it in DlgTemplates.xml)

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

Re: cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

It's DlgBatesNumberingFiles - the dialog is also being reused in the Add Bates Numbering Multi operation.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: cmd.newDocCombine options

Post by zarkogajic »

Hi Alex,

Thanks. I saw that one but was not sure ...

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

cmd.newDocCombine options

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply