SearchKeyString
Declaration
Delphi
function SearchKeyString(SearchText, FontName: PAnsiChar; res: PFinderResult; var resLen: Cardinal) : LongBool; stdcall;
ActiveX
HRESULT _stdcall SearchKeyString([in] BSTR SearchString, [in] BSTR FontName, unsigned int* SearchResult, [in, out] unsigned long* ResultLen, [out, retval] VARIANT_BOOL* res);
Arguments
Argument | Description |
---|---|
searchString | The text you want to search for. |
fontName | Not in use right now |
searchResult | Struct of the search result |
resLen | Length of the struct |
Return value
- will be added soon -
Description
This function is used to search strings in a PDF document. Such a string can be useful as anchor to help setting the correct signature position, for example in a dynamic document, where the content is always different and so the position of the signature does not have fixed coordinates. The function also works well with "invisible" text (white text on white background) or very small text sizes.
The struct, which you get back from the function, contains the coordinates of all positions, at which the search string was found in the document. The values are the coordinates of the top left and bottom right corners as well as the pagenumbers.
C# sample
//STRUCT public struct SearchResult { public int XmlFieldIndex; public int FieldType; public int PageNumber; public double Left; public double Top; public double Right; public double Bottom; } //resLen must not be zero uint resLen = maxSearchResultLen; int size = Marshal.SizeOf(res[0]); IntPtr ptr = Marshal.AllocHGlobal((int)resLen*size); IntPtr tmpPtr = ptr; uint pstruct = (uint)ptr; bool result = false; pageList.Items.Clear(); Â try { result = SignAPIv4.SearchKeyString(textBox6.Text, "", ref pstruct, ref resLen); for (int i=0; i< resLen; i++) { res[i] = (SearchResult)Marshal.PtrToStructure((IntPtr)pstruct, typeof(SearchResult)); tmpPtr = (IntPtr)((int)tmpPtr + Marshal.SizeOf(typeof(SearchResult))); pstruct = (uint)tmpPtr; pageList.Items.Add(i+1); } x1 = res[0].Left(); y1 = res[0].Top(); x2 = res[0].Right(); y2 = res[0].Bottom(); page = res[0].PageNumber.ToString(); }
Â