GetSubPoint not working

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

GetSubPoint not working

Post by jykim »

Hi,

Could someone tell me what the problem is with the following code?

Code: Select all

short type = OLE.VT_BYREF | OLE.VT_VARIANT;
int ptr = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
		
Variant spDoc = new Variant(ptr, type); 
		
auto.invoke(
	getDispatcherId("DoVerb"), 
	new Variant[] { 
		new Variant("Documents[#4095]"),
		new Variant(".SP"),
		new Variant(),
		spDoc,
		new Variant(0)
	});
		
OleAutomation autoDoc = spDoc.getAutomation();
		
Variant pageCount = new Variant(ptr, type);
autoDoc.invoke(
	getDispatcherId(autoDoc, "GetProperty"), 
	new Variant[] { 
		new Variant("Pages.Count"),
		pageCount,
		new Variant(0)
	});
		
System.out.println("page count=" + pageCount.getInt());

Variant spPageChars = new Variant(ptr, type);
autoDoc.invoke(
	getDispatcherId(autoDoc, "GetSubPoint"), 
	new Variant[] { 
		new Variant("Pages[1].Text.Chars"),
		spPageChars
	});
		
OleAutomation autoPageChars = spPageChars.getAutomation();
		
Variant pageCharsCnt = new Variant(ptr, type);
autoPageChars.invoke(
	getDispatcherId(autoPageChars, "GetProperty"), 
	new Variant[] { 
		new Variant("Count"),
		pageCharsCnt,
		new Variant(0)
	});
		
System.out.println("char count=" + pageCharsCnt.getInt());
It looks like "GetSubPoint" is not working.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: GetSubPoint not working

Post by Corwin - Tracker Sup »

Instead of your declaration

Code: Select all

Variant spPageChars = new Variant(ptr, type);
try to use next code:

Code: Select all

Variant spPageChars = new Variant(OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof), (short)(OLE.VT_BYREF | OLE.VT_DISPATCH));
HTH
jykim
User
Posts: 37
Joined: Fri Oct 02, 2009 12:30 am

Re: GetSubPoint not working

Post by jykim »

Wonderful! Thanks a lot Corwin! :D
User avatar
Chris - PDF-XChange
Site Admin
Posts: 798
Joined: Tue Apr 14, 2009 11:33 pm

Re: GetSubPoint not working

Post by Chris - PDF-XChange »

As always, glad to help :)
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.


Chris Attrell
Tracker Sales & Support North America
http://www.tracker-software.com