PXCp_ET_GetPageContentAsTextW fails in C#  SOLVED

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
aalborg energie technik
User
Posts: 1
Joined: Wed Mar 14, 2012 7:30 am

PXCp_ET_GetPageContentAsTextW fails in C#

Post 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);
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: PXCp_ET_GetPageContentAsTextW fails in C#  SOLVED

Post 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
Post Reply