Search Text in PDFViewWPF - pdf

I'm using PDFNet to display PDF-files in my WPF application.
I need to provide a search mode where one can enter a search term which will be searched in the whole PDF-file. I found FindText in the documentation, but it doesn't seem to work properly. If I'm going to execute the method I can see a thread ending in my console output in Visual Studio - so it seems to run.
If I'm going to click the button multiple times the view will be scrolled to the corresponding find results but sometimes (or mainly) the text will not be selected.
The method which will be executed looks like the following:
private void Toolbar_DocumentSearch_Click(System.Object sender, System.Windows.RoutedEventArgs e) {
if (this.TbSearchTerm.Text.Length > 0) {
_pdfview.FindText(this.TbSearchTerm.Text, false, false, false, false);
}
}
Any hint on what I'm doing wrong?
Additional information:
If I've searching through the whole document, it starts from the beginning. Then the first find result will be selected but none other until the next find result is on the next page.

The built it in text search in PDFViewWPF is the type of search you get when you typically select ctrl-f when viewing.
PDFViewWPF.FindText does search the entire document, but does not display all the results in a window or control
You can add your own full text search control using the TextSearch class.
https://www.pdftron.com/pdfnet/samplecode/TextSearchTest.cs.html

Related

Search text file and put matching results in listbox

I have a VB.NET project in which there is a form where there is a TextBox control, a ListBox control and an external text file that contains a list of outlook folder paths for client emails.
Essentially, the user enters into the text box the name of a client and/or their unique reference number, presses the search button (yes - I know I could make the results appear as they type, I want a button!) and it comes up with the matching results for the company name or serial number that are in the text file and puts them in the list box, with the full path of the outlook email folder.
For example:
If I put into the textbox: "06967759-274D-40B2-A3EB-D7F9E73727D7"
It would put the following result into the listbox:
"EIS Admin\Contacts{06967759-274D-40B2-A3EB-D7F9E73727D7}"
And the user can then go to that folder and find the email(s).
I have gone through several revisions both of my own code and code pasted from online with people having the same issue, only to have Visual Studio throw no errors, run the code and have no luck, with it doing nothing but clearing the list box, and not showing matching results of any kind.
I understand this may be a repeat question but I am extremely confused, can't get anything to work and need some help regarding my issue.
Here is the current code (from online - not mine):
lbx_OFL_Results.Items.Clear()
Dim i As Integer
For i = 0 To lbx_OFL_Results.Items.Count - 1
If i > lbx_OFL_Results.Items.Count - 1 Then Exit For
If Not lbx_OFL_Results.Items(i).Contains(tbx_FindText.Text) Then
lbx_OFL_Results.Items.Remove(lbx_OFL_Results.Items(i))
i -= 1
End If
Next
The list box is called "lbx_OFL_Results"
The textbox is called "tbx_FindText"
I start by clearing the list box of all items (when the form loads, it fills the list box will all lines of the text file, so I need to clear it).
Form Load Event Code:
Dim lines1() As String = IO.File.ReadAllLines("C:\ProgramData\WPSECHELPER\.data\Outlook Folder Wizard\outlookfolders.txt")
lbx_OFL_Results.Items.AddRange(lines1)
For the rest of the code it seems to be doing some form of a 'sort search' then removing any excess results.
If anyone can suggest edits to my code, or new code then that would be sublime.
Thanks.
Thanks to #Jimi for the answer.
Code:
listbox.Items.Clear()
listbox.BeginUpdate()
For i as Integer = 0 To lines1().Length - 1
If lines1(i).Contains(searchbox.Text) Then
listbox.Items.Add(lines1(i))
End If
Next
listbox.EndUpdate()
I have another question which solves how to make this search non case-sensitive. It can be found here.

3 searchbox with 3 question marks, Sikuli Fails to click 2nd element

I have 3 search box field and 3 question marks near by each search box. If I try to click on the 2nd question mark, It always clicks the 2nd Search box instead of clicking the question mark button. [Sikuli not clicking the exact element]1 Kindly have a look into the below image i have attached. Click "1" to view the image... Pls dont come up with coordinates. I shouldn't use coordinates in my project.
Well, this may not be the fully qualified answer, which do not use Region, Co-ordinates & autoIT as you are expecting.
This is code in Sikuli which uses findAll() method.
I created a dummy window as per your screenshot as below:
Edit
public void clickButton() throws AWTException, FindFailed
{
m_sikscr=new SikuliScript();
m_screen=new Screen();
m_sikscr.switchApp("Java Swing Examples");
m_screen.wait((double)3.0);
int i=0;
Match[] array=new Match[5];
Iterator<Match> rs1 = m_screen.findAll(new Pattern("./img/Button1.png"));
while(rs1.hasNext())
{
array[i]=rs1.next();
i++;
}
m_screen.click(array[1]);
}
This clicks only the second button on screen.
Hope this much triggers the thought of making it work completely.

QTP - Clicking on a button with a given value

I've started using QTP last weekend so I'm still a bit confused about some things.
I've coded a function that opens an URL on IE, performs some actions and writes a report. But I have a little problem: at a certain point the function has to click on a button to go on but this button's value is changed at every refresh of the page.
For example: at the first access the button's value (or label) is "Results List (51)" but, if I refresh the page, the value becomes "Results List (11)".
What changes is the number inside the brackets (that identifies the number of results inside the list).
Obviously I recorded the action only one time and the result is this:
Browser("myBrowser").Page("myPage").Frame("myFrame").WebButton("Results List 51)").Click
How can I click on the button without having to worry about it's value?
You should open the object repository and have a look at the description that was create for your WebButton then make the property in question a regular expression.
In your case the value should be Results List \(\d+\), this means Result List followed by open-parentheses, followd by one or more digits (a number) followed by close-parentheses.
Here's an explanation on how to use regular expressions in UFT.
This question reminded me of the days when I was a beginner in QTP ;) I think I still am!
Coming to your question -
If you don't really care about what is inside the brackets then you can just give Results List*.* but if you want to check if there is a bracket and digits within it then use the value suggested by Motti i.e. Results List (\d+)
Detailed Steps as you are a rookie:
1) Go to Resources->Object Repository
OR
In the Resources pane expand your action and double-Click the local object repository (You recorded hence the objects will be in local)
2) Click on the Concerned Object so that the object properties specific to this object is displayed.
3) Select the property (name?), at the extreme right you will see a button to configure the value, click on it.
4) Type the text Results List (\d+) or Results List*.*, select the checkbox for regular expressions.
5) A message box will appear, Click on No and then OK button.
Your script should run now!

SSRS Report Builder - Only Show Header On First Page (With Page Numbers)

So I am running into the problem where my report header is being displayed on every page, but I only want to display it on the first page. The solution that people on this forum have given is to just put the header in the main content. The problem with this is that my header shows the page number + total pages (i.e. Page 1 of 3 pages). I cannot move my header to the body because I will lose access the page numbers. For some reason, Report Builder will only allow you to have access to the page numbers via the header. Does anyone have any solution to this problem?
Write an expression to hide the textboxes that hold the header information.
The expression would look like this:
=iif(Globals!PageNumber = 1, FALSE, TRUE)
To get to the expression property:
right-click text box >> text box properties >> visibility >> select "Show or hide based on expression" >> insert expression above
cheers
I had the same issue, where I only wanted the header to show on the first page. The solution I came up with was to stick all of my objects from the header into a rectangle, so it was now acting as a container. I then placed that container into the body. In the report properties, in the code section, I borrowed from this post Access Page number in report body In SSRS to create functions, which would allow me to pull the page numbers into the body section. Then in my rectangle/container, I set the visibility property to =code.PageNumber>1. I hope this helps!
I did this, just to make it easier the two functions you want to add to the Report that were linked above are,...
Function PageNumber() As String
Return Me.Report.Globals!PageNumber
End Function
Function TotalPages() As String
Return Me.Report.Globals!TotalPages
End Function

Setting Focus on DataGridView Control programmatically in Visual Basic

I want to programmatically set the focus to the last row (bottommost, its only one column wide) in the DataGridView control for Visual Basic. How can I do so?
So far, I have tried
DGV.Rows.GetLastRow(DataGridViewElementStates.Selected)
without success, though I did not expect that to work.
It absolutely must select that last cell. Otherwise, the application is nearly impossible to use!
Here is a screenshot of what I am making with this: http://www.mediafire.com/?mmyogzytgzt
The "Paste Clipboard Contents" button only pastes into the selected cell, though I guess I could find a workaround.
I solved it. I used a workaround to add the text in directly. I don't need this anymore!
To select the last column, last row in c# (sorry I don't have a vb project I'm working right now:
this._dg.ClearSelection(); // eliminates what they already have selected if you need
this._dg[this._dg.ColumnCount-1, this._dg.RowCount-1].Selected = true;
In VB.net replace 'this' with 'me', and [] with ().
This is also useful:
this._dg.Focus();
this._dg.CurrentCell = this._dg[this._dg.ColumnCount - 1, this._dg.RowCount - 1];
this._dg.BeginEdit(false); // true if you want all text highlighted
// for deletion or replacement