Page 1 of 1

PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 7:42 pm
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?

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 8:01 pm
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,

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 8:13 pm
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

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 8:33 pm
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,

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 8:35 pm
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.

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 8:45 pm
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,

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 8:50 pm
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?

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Mon Aug 27, 2012 11:04 pm
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,

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Tue Aug 28, 2012 11:18 am
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!

Re: PXCp_llGetObjectByIndex returns "Invalid Index"

Posted: Tue Aug 28, 2012 12:28 pm
by Tracker Supp-Stefan
Glad we could help afalsow!

Cheers,
Stefan