The SearchTextEx method is used to search for a specific text with WinAnsi encoded streams or Unicode.
System.Boolean SearchTextEx(System.Int16 Start, System.String Text, [out] System.Int32 Page, [out] System.Double xPos, [out] System.Double yPos)
Start
(-1): Start from the beginning of the document, otherwise start from the previous Search position.
Text
Text to search for.
Page
This is a return value that contains the page number (one based index) where text was found.
xPos
This is a return value of the x coordinate where the text was found.
yPos
This is a return value of the y coordinate where the text was found.
It returns True if successful and False otherwise.
SearchTextEx method is more accurate in returning the text position but much slower than SearchText method.
Member of CDIntfEx.Document.
Public Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
' Declare a new cdintfex document if it does not exist in the form.
Dim pdfDoc As New CDIntfEx.Document
' The SetLicenseKey method should be called after creating an object of type
' CDIntfEx.Document to activate the advanced methods that require the object
' activation code to work properly
pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)
' Open the document
pdfDoc.Open("c:\temp\test.pdf")
' Search Text
Dim xPos As Double
Dim yPos As Double
Dim page As Long
Dim strFind As String = "Test"
If pdfDoc.SearchTextEx(0, strFind, page, xPos, yPos) Then
MsgBox("SearchText: " & strFind & " String Found!" & Environment.NewLine &
"Page=" & page & ", Position Horizontal=" & xPos & ", Position Vertical=" & yPos)
Else
MsgBox("SearchText: " & strFind & " String Not Found!")
End If
End Sub
public void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Converter Evaluation";
const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
// Declare a new cdintfex document if it does not exist in the form.
CDIntfEx.Document pdfDoc = new CDIntfEx.Document();
// The SetLicenseKey method should be called after creating an object of type
// CDIntfEx.Document to activate the advanced methods that require the object
// activation code to work properly
pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);
// Open the document
pdfDoc.Open(@"c:\temp\\test.pdf");
// Search Text
double xPos = 0;
double yPos = 0;
int page = 0;
string strFind = "Test";
if (pdfDoc.SearchTextEx(0, strFind, ref page, ref xPos, ref yPos))
{
MessageBox.Show("SearchText: " + strFind + " String Found!" + Environment.NewLine +
"Page=" + page + ", Position Horizontal=" + xPos + ", Position Vertical=" + yPos);
}
else
{
MessageBox.Show("SearchText: " + strFind + " String Not Found!");
}
}