Skip to end of metadata
Go to start of metadata



function SearchKeyString(SearchText, FontName: PAnsiChar; res: PFinderResult; var resLen: Cardinal) : LongBool; stdcall;


HRESULT _stdcall SearchKeyString([in] BSTR SearchString, [in] BSTR FontName, unsigned int* SearchResult, [in, out] unsigned long* ResultLen, [out, retval] VARIANT_BOOL* res);




The text you want to search for.

fontNameNot in use right now
searchResultStruct of the search result
resLenLength of the struct


Return value

- will be added soon -


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

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;
	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;
	x1 = res[0].Left();
	y1 = res[0].Top();
	x2 = res[0].Right();
	y2 = res[0].Bottom();
	page = res[0].PageNumber.ToString();




  • No labels