Page 1 of 1

PXCp_ET_GetPageContentAsTextW fails in C#

Posted: Fri Jan 12, 2018 2:18 pm
by aalborg energie technik
Hi
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);

Re: PXCp_ET_GetPageContentAsTextW fails in C#  SOLVED

Posted: Fri Jan 12, 2018 4:11 pm
by Tracker Supp-Stefan
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:
https://help.pdf-xchange.com/DEV/de ... entastextw

Cheers,
Stefan