Page 1 of 1

Searching for page number

Posted: Fri May 25, 2007 2:19 pm
by isoft
Hi

Is there maybe a way to find a number of page that has specific word in it after the page has been rendered, but before it is shown in print preview. For example, I have a list of peoples names with 10000 names that are spread over 50 pages. What I need to do is find the page number on which the name "John" is.
I need to do it from my application. I think that the code for that should go something like this:

Code: Select all

Dim rpt As New Stimulsoft.Report.StiReport

rpt.Load("Report.mrt")

rpt.RegData(MyDataSet)

rpt.Compile()
rpt.Render()

'The code for finding the page number which has the word in it
I hope there's a way because it would help me extremely.

Thanks!

ivan

Searching for page number

Posted: Sat May 26, 2007 2:39 am
by Vital
You can use following code:

Code: Select all

Dim stringToFind As String
Dim page As StiPage
Dim PageIndex As Integer
For Each page In rpt.RenderedPages
  Dim component As StiComponent
  For Each component In page.GetComponents
    Dim text As IStiText = TryCast(component,IStiText)
    If (((Not text Is Nothing) AndAlso (Not text.Text Is Nothing)) AndAlso (Not text.Text.Value Is Nothing)) Then
      Dim str As String = text2.Text.Value
      If str = stringToFind Then 'We have find pagenumber      
  Next
Next

Searching for page number

Posted: Sat May 26, 2007 4:44 am
by isoft
Thank You very much for Your reply! You guys are great! It works just like I need it to work.

One more thing. Is there a way to show in the print preview only the pages from 6 to 20 for instance? I need it because when I find the word on a page (lets say page 6), I need to print only that page and the ones that follow.

Thanks again for Your help!

Searching for page number

Posted: Sat May 26, 2007 6:55 am
by Vital
You can use following code:

Code: Select all

Dim StartIndex As Integer = 6
Dim EndIndex As Integer = Report.RenderedPages.Count - 20

Do While (EndIndex > 0)
  Report.RenderedPages.RemoveAt(Report.RenderedPages.Count - 1)
  EndIndex -= 1
Loop

Do While (StartIndex > 0)
  Report.RenderedPages.RemoveAt(0)
  StartIndex -= 1
Loop
Thank you.

Searching for page number

Posted: Sat May 26, 2007 8:35 am
by isoft
Great! Thanks!