PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

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

aalborg energie technik
Topic Author
Posts: 1
Joined: Wed Mar 14, 2012 7:30 am

PXCp_ET_GetPageContentAsTextW fails in C#

Fri Jan 12, 2018 2:18 pm

Somehow I get the error: "Invalid function call sequence" when trying to get text. I know positively that the document contains searchable text.
What am I doing wrong?

Here is my code:

int res;
int pdf;
int numPagesInPdf = 0;

res = XCPro40_Defs.PXCp_Init(out pdf, XCPro40_Defs.g_SDKRegKey, XCPro40_Defs.g_DevCode);
res = XCPro40_Defs.PXCp_ReadDocumentW(pdf, fileFullPath, 0);
res = XCPro40_Defs.PXCp_GetPagesCount(pdf, out numPagesInPdf);

XCPro40_Defs.PXP_TETextComposeOptions txtComposeOptions;
XCPro40_Defs.PXCp_ET_GetCurrentComposeParams(pdf, out txtComposeOptions);

IntPtr pBuffer = IntPtr.Zero;
int bufferLen = 0;
for (int i=0; i<numPagesInPdf; i++)
res = XCPro40_Defs.PXCp_ET_GetPageContentAsTextW(pdf, i, ref txtComposeOptions, out pBuffer, ref bufferLen);
if (res < 0)
PXCp_Error.ShowDSErrorString(this, res);
res = XCPro40_Defs.PXCp_Delete(pdf);
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13009
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: PXCp_ET_GetPageContentAsTextW fails in C#  SOLVED

Fri Jan 12, 2018 4:11 pm

Hello aalborg energie technik,

I can't see where you are calling the PXCp_ET_Prepare(hDoc); method.

PXCp_ET_Prepare analyses the document structure and stores the collected information in an internal data storage area, which may then be used during actual text extraction. Be aware that this function should be called before any other functions related to text extraction, and must be be followed by calling PXCp_ET_Finish to free the internal data storage and temporary buffers.

Please take a look at the sample code here:
http://help.tracker-software.com/DEV/de ... entastextw


Who is online

Users browsing this forum: No registered users and 5 guests