Okay now i now the problem:
`
returnArgs = e;
this.Dispatcher.BeginInvoke((System.Action)delegate()
{
this.ListSearchResults.Items.Clear();
});
SearchResults.Clear();
hlt_list.Clear();
if (_viewer.GetDoc() != null)
textSearch = new pdftron.PDF.TextSearch();
else
throw new Exception(“WholeDocumentSearchControl Document property cannot be null.”);
pdftron.PDF.TextSearch.SearchMode mode = (e.Argument as InformationForSearch).Mode;
textSearch.Begin(_document, SearchTerm, (Int32)mode, 1, _viewer.GetPageCount());
FoundCount = 0;
CurrentPage = 0;
int page_num = 0;
String result_str = string.Empty;
String ambient_str = string.Empty;
Highlights hlts = new Highlights();
try
{
while (true)
{
System.Threading.Thread.Sleep(1);
_document.Lock();
if (bw.CancellationPending)
{
_document.Unlock();
returnArgs.Cancel = true;
return;
}
hlts = new Highlights();
resultCode = textSearch.Run(ref page_num, ref result_str, ref ambient_str, hlts);
CurrentPage = textSearch.GetCurrentPage();
bw.ReportProgress(CurrentPage);
if (resultCode == pdftron.PDF.TextSearch.ResultCode.e_found)
{
SearchResult result = new SearchResult(page_num, result_str, ambient_str, hlts);
SearchResults.Add(result);
hlt_list.Add(hlts);
FoundCount++;
this.Dispatcher.BeginInvoke((System.Action)delegate()
{
TextBlock b = new TextBlock();
TextBlock t = new TextBlock();
b.Text = result.AmbientString;
t.Text = result.ToolTipString;
FormatText(ref b, result.ResultString, FontWeights.Bold);
FormatText(ref t, result.ResultString, FontWeights.Bold);
ToolTipService.SetToolTip(b, t);
ListSearchResults.Items.Add(b);
});
_document.Unlock();
}
else if (resultCode == pdftron.PDF.TextSearch.ResultCode.e_page)
{
_document.Unlock();
}
else
{
_document.Unlock();
return;
}
}
}
catch (pdftron.Common.PDFNetException ex)
{
_document.Unlock();
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
`
okay when the code runs in the backworker thread like the example from your software the i get after 1200 page the PDFNetexception (ex). The exception means that it was try to load a wrong file! I don’t know why because i am not change the document or other things.
What can be the problem!
Am Freitag, 8. November 2013 11:33:52 UTC+1 schrieb Daniel Lutz:
Hello
i used the wpf example from the viewer control to build an custom textsearch. (with search result count). when i reselected the result with:
_viewer.Select(_selections[_selectionIndex]); _viewer.SetVScrollPos(_viewer.GetVScrollPos()); _viewer.SetHScrollPos(_viewer.GetHScrollPos()); var b = _viewer.HasSelection();
_selections[_selectionIndex] is an object from type HIGHLIGHTS.
when i use select(highlights highlight) then _viewer.HasSelection() is true but i didn’t see
the highlighted text in the document. When i start the samplecode then it start normaly!
Daniel