Is there a way of highlighting multiple search terms in the converted swf file?
Currently I can see that in javascript i can use searchtext() function to highlight the first occurrence of the search term. Is there a way of performing searchAll that can highlight all occurrences at once.
If this is not directly supported, is there any work around of achieving this behavior.
Waiting for the reply.
Thanks,
gaurav
Highlight multiple occurrence of a search term
-
- Posts:1
- Joined:Thu Aug 28, 2008 1:13 am
Re: Highlight multiple occurrence of a search term
In current version of Print2Flash there is no direct API for highlighting all occurrences of a search term in a converted document. However, such behavior may be implemented using Print2Flash Document API invoked from Flash AS2 movies. For example, you may use this code to highlight text from symbols 10 to 19 and from 30 to 39 on the first document page:
To determine which symbols to highlight, you may retrieve page text using this additional code:
and search for all occurrences of the required search term in it.
Code: Select all
var sh=p2f.getPage(1).getTextSnapshot()
sh.setSelected(10,20,true)
sh.setSelected(30,40,true)
Code: Select all
var text=sh.getText(0,sh.getCount())
Re: Highlight multiple occurrence of a search term
I can get this to work with the sample document provided in the SDK but I can't do it with any of the documents I generate. In the docapisample.fla I try to get the following
For your sample document this is 884 as expected. In all the documents that I generate (either through the API or through the print menu) it's 0. Note that I checked the following:
1. I set the PROTECTION_OPTION option properly (i.e., I allow programmatic access and don't disallow accessing the text - if I don't I get "undefined" not 0)
2. I wait that the document is fully loaded (this is calculated after clicking on the a button - on a side, trying to search the document right after it is loaded, even using your loading code example, does not work right away).
3. I can select text and search the document using your API.
Any help would be very appreciated.
Code: Select all
_root.MyDoc.getPage(1).getTextSnapshot().getCount()
1. I set the PROTECTION_OPTION option properly (i.e., I allow programmatic access and don't disallow accessing the text - if I don't I get "undefined" not 0)
2. I wait that the document is fully loaded (this is calculated after clicking on the a button - on a side, trying to search the document right after it is loaded, even using your loading code example, does not work right away).
3. I can select text and search the document using your API.
Any help would be very appreciated.
Re: Highlight multiple occurrence of a search term
Is it possible that I hit this problem because I am testing the unregistered version? It works as well when I use documents converted through your website.
Re: Highlight multiple occurrence of a search term
I just bought a server version of your software and I am still getting the same issue. This is critical for us as we need to be able to find text in the page.
Re: Highlight multiple occurrence of a search term
I have found the issue (but still haven't found print2flash's support...). They now have a submovie called realmovie that contains the text. So you need to do
Code: Select all
p2f.getPage(1).realMovie.getTextSnapshot()
Re: Highlight multiple occurrence of a search term
For the latest version you need to use a slightly modified code in order to make multiple text selections work properly:
This code uses an undocumented GetTextSnapshot function to get a text snapshot. The argument to this function is a page number starting from zero.
Code: Select all
var sh=p2f.GetTextSnapshot(0) // first page
sh.setSelected(5,10,true)
sh.setSelected(15,20,true)