DataIn with multiple arguments

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

DataIn with multiple arguments

Post by jykim »

I'm trying to implement 'HighlightSelection' in my SWT application using SWT's ActiveX support.

Code: Select all

DoVerb("Documents[0]", "HighlightSelection", DataIn(0x800080, 0.65), NULL, 0);
The method requires two input arguments, but I don't know how to pass that DataIn parameter since the below code is not valid.

Code: Select all

Variant[] dataIn = new Variant[] { new Variant(0x800080), new Variant(0.65) };
		
auto.invoke(
	getDispatcherId("DoVerb"), 
	new Variant[] { 
		new Variant("Documents[0]"),
		new Variant("HighlightSelection"),
		dataIn,
		new Variant(),
		new Variant(0)
	});
Please help!
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: DataIn with multiple arguments

Post by Stefan - PDF-XChange »

Hi jykim,

Unfortunately no one in our team has enough knowledge in Java and SWT, to directly help you solve your problem.

We ran a simple example test with String[] and String arguments in a Variant[] and it didn't even want to compile, so we do believe the problem is with trying to mix array and non-aray elements.

Please let us know if you find a solution/workaround on this.

Best Regards,
Stefan
jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

Re: DataIn with multiple arguments

Post by jykim »

Thanks Stefan for looking into this.
It basically comes down to how to create "SafeArray" as input in Java/SWT.
I know there are some users in this forum, who are dealing with Java/SWT for this Viewer SDK.
Could anyone please help me out here?
jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

Re: DataIn with multiple arguments

Post by jykim »

I've tried creating safearray following this example http://it.comegoogle.com/examples/Code/ ... EARRAY.htm, but it didn't work out.

I really need to make this work, otherwise I can't use PDF-XChange Viewer.
Please help!
jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

Re: DataIn with multiple arguments

Post by jykim »

Dear Support team,

Is there any chance that you can make new APIs available for doing this, not using "safearray" as input or output?
For example, instead of doing this,

Code: Select all

DoVerb("Documents[0].Pages[0].Text", "Select", DataIn(0, 10, 1), DataOut, 0);
have a new API such as,

Code: Select all

Invoke("Documents[0].Pages[0].Text.Select", 0, 10, 1);
or,

Code: Select all

textObj = Documents[0].Pages[0].Text;
textObj.Select(Long offset, Long length, Long flag);
Please let me know if it's possible for you to make such APIs that's possible for us to use.
Thanks!
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: DataIn with multiple arguments

Post by Corwin - Tracker Sup »

Hello jykim,

In new build you will be able to use our own implementation of SafeArray. To get this array you may use next code:

Code: Select all

Variant dataOut=new Variant(OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof), (short)(OLE.VT_BYREF | OLE.VT_I4));
auto.invoke(getDispId("DoVerb"), 
           		new Variant[] {
            	new Variant(""),
            	new Variant(".ARGS"),
            	new Variant(""),
            	dataOut,
            	new Variant(0)});
OleAutomation Args = dataOut.getAutomation();
Adding items to array:

Code: Select all

Args.invoke(getDispId(Args,"Add"),
	new Variant[]{
	new Variant("SomeString")}); // Add string

Args.invoke(getDispId(Args,"Add"),
	new Variant[]{
	new Variant(12345)}); // Add integer
Then you will be able to pass this array to DoVerb function

Code: Select all

auto.invoke(getDispId("DoVerb"), 
          		new Variant[] {
              	new Variant(""),
              	new Variant("OpenDocument"),
              	new Variant(Args),
              	new Variant(),
              	new Variant(0)});
HTH.
jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

Re: DataIn with multiple arguments

Post by jykim »

That's wonderful! You guys rock!
By the way, I see that you have new version (v.2.042.6) released today. Is this API for SafeArray included in this version? Or, is it going to be included in the next release?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: DataIn with multiple arguments

Post by Vasyl - PDF-XChange »

The build v.2.042.6 contains this feature already.

Thanks.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

Re: DataIn with multiple arguments

Post by jykim »

Thanks Vasyl and Corwin!
I was able to make it work after I changed the Variant type with "OLE.VT_BYREF | OLE.VT_VARIANT".
Corwin - Tracker Sup wrote: In new build you will be able to use our own implementation of SafeArray. To get this array you may use next code:

Code: Select all

Variant dataOut=new Variant(OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof), (short)(OLE.VT_BYREF | OLE.VT_I4));
...
...
Changed to

Code: Select all

Variant dataOut=new Variant(OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof), (short)(OLE.VT_BYREF | OLE.VT_VARIANT));
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: DataIn with multiple arguments

Post by John - Tracker Supp »

Thanks and pleased you got there ;)
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