PXCp_llGetObjectByIndex returns "Invalid Index"

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

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

Post Reply
afalsow
User
Posts: 17
Joined: Thu Jun 14, 2012 1:28 pm

PXCp_llGetObjectByIndex returns "Invalid Index"

Post by afalsow »

I execute the following, in order:
  • PXCpVB_ReadDocumentW (returns "0")
    PXCp_ET_Prepare (returns "0")
    PXCp_ET_AnalyzePageContent (returns "1108289444")
    PXCp_GetPagesCount (returns "4", which is correct)
    PXCp_llGetObjectsCount (returns "64", which seems quite reasonable)
I then execute PXCp_llGetObjectByIndex, which fails with "Invalid Index"
Any index (I tried 0...5) fails (I don't recall if zero-based).

The documentation does not indicate any requirement of any other prerequisite function. What am I missing?
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by Nico - Tracker Supp »

Hi afalsow,

Thank you for your post.
We need more information about the context of that function call.
Please send a code sample which we can compile and run to support@pdf-xchange.com
Thanks.

Sincerely,
afalsow
User
Posts: 17
Joined: Thu Jun 14, 2012 1:28 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by afalsow »

I've only begun experimenting with the SDK a few days ago, working with the sample VB_XCPro40Demo. I've simply added a small sub to do my tinkering... one function at a time.

Private Sub Command1_Click()
Dim res As Long
Dim pdf_new As Long
Dim Ocnt As Long

res = PXCp_Init(pdf_new, g_initstr, g_initDevCode)
res = PXCpVB_ReadDocumentW(pdf_new, "e:\!test.pdf", 0) '[ 4 pages ]
res = PXCp_ET_Prepare(pdf_new)
res = PXCp_ET_AnalyzePageContent(pdf_new, 1)
res = PXCp_GetPagesCount(pdf_new, Ocnt)
res = PXCp_llGetObjectsCount(pdf_new, Ocnt)
res = PXCp_llGetObjectByIndex(pdf_new, 1, Ocnt)
res = PXCp_ET_Finish(pdf_new)
end sub
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by Nico - Tracker Supp »

Hi afalsow,

Thank you for your post.
Please let me ask you why are you analyzing the second page and not starting from the first page which is page number 0?
Try with the following:
res = PXCp_ET_AnalyzePageContent(pdf_new, 0);
instead of:
res = PXCp_ET_AnalyzePageContent(pdf_new, 1);
Thanks.

Sincerely,
afalsow
User
Posts: 17
Joined: Thu Jun 14, 2012 1:28 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by afalsow »

I made the change, replacing 1 with 0.

No change in behavior. Same results at every function/step.

As to why I was analyzing 1 instead of 0... just an arbitrary selection. Based on documentation (your function PXCp_ET_AnalyzePageContent appears to deal primarily with text elements), I felt the function may not even be necessary as a preparatory step for executing PXCp_llGetObjectByIndex.

At this point in experimentation, my goal is simply to access each object to see what information is available for each object.
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by Nico - Tracker Supp »

Hi afalsow,

Thank you for your reply.
Are you sure your pdf document is a valid one?
I'm running this code snippet that is identical to yours without any issues.
Also make sure this function works properly: res = PXCpVB_ReadDocumentW(pdf_new, "e:\!test.pdf", 0)
The name "!test.pdf" is not a proper name for a pdf document.
Adding special characters to file names is not a standard practice.

Code: Select all

HRESULT res;
DWORD Ocnt;
PDFDocument pdf_new = NULL;
LPCSTR g_initstr = "<Enter here valid key>";
LPCSTR g_initDevCode = "<Enter here valid developer's code>";
LPCSTR FileName = "C:\\testFile.PDF";
HPDFOBJECT hPdfObj;

res = PXCp_Init(&pdf_new, g_initstr, g_initDevCode);
res = PXCp_ReadDocumentA(pdf_new, FileName, 0);
res = PXCp_ET_Prepare(pdf_new);
res = PXCp_ET_AnalyzePageContent(pdf_new, 0);
res = PXCp_GetPagesCount(pdf_new, &Ocnt);
res = PXCp_llGetObjectsCount(pdf_new, &Ocnt);
res = PXCp_llGetObjectByIndex(pdf_new, 1, &hPdfObj);
res = PXCp_ET_Finish(pdf_new);
Thanks.

Sincerely,
afalsow
User
Posts: 17
Joined: Thu Jun 14, 2012 1:28 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by afalsow »

The pdf file is valid. It opens properly and displays completely properly in Adobe Reader.

Yes, res = PXCpVB_ReadDocumentW(pdf_new, "e:\!test.pdf", 0) executes properly. (I use "!" to indicate the file is for testing, and so it places high in file directory listings... just a matter of convenience during testing)

The pagecount returned is 4, which is correct.

I have renamed the file to "test.pdf" and run my sample.
There is no change in results.

I notice your code is C; mine is VB. Have you tried this in a VB sample?
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by Nico - Tracker Supp »

Hi afalsow,

Yes, I ran it in VB.NET and everything works fine.
Please could you show me the DLL import of those functions in Visual Basic?
Are you sure they are well defined? For example, arguments are properly passed by reference and by value, types agree, etc.
Thanks.

Sincerely,
afalsow
User
Posts: 17
Joined: Thu Jun 14, 2012 1:28 pm

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by afalsow »

VB6: Function PXCp_llGetObjectByIndex Lib "xcpro40" (ByVal Doc As Long, ByVal index As Long, ByRef pObject As Long) As Long


Just ran my sample again, first test for the day. :shock: And it worked!

I'm very sorry... I have no idea how it did not work yesterday and now it does. :?

My evaluation/learning curve continues...

Many thanks to Tracker support!
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Post by Tracker Supp-Stefan »

Glad we could help afalsow!

Cheers,
Stefan
Post Reply