swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Swftools-common] Text search in SWF


From: Andreas Haufler \(scireum\)
Subject: RE: [Swftools-common] Text search in SWF
Date: Thu, 20 Aug 2009 11:21:36 +0200

Change line 17 to:

               snapText = (img.content as MovieClip).textSnapshot;

 

…then you can happily fall asleep…

 

(you need to geht the textSnapshot of the loaded MovieClip, not the loader itself. This is also the reason why you need Flash 9 swfs which you load. Because older swfs are loaded as AVM1Movie (or something like this) which don’t support textSnapshot.)

 

 If you ever plan to load those SWFs via the internet, make sure your security domain and stuff is set currently.

 

We do something like:

 

                                               if (Security.sandboxType == Security.REMOTE) {

                                                                              loader.loaderContext = new LoaderContext(false, null, SecurityDomain.currentDomain);

                                               }

 

…before we load the swf.

 

Best regards

andy

 

 

freundliche Grüße
scireum - Ein Unternehmen der TTI GmbH

i.A. Andreas Haufler
Projektleiter scireum

-------------------------------------------------------------------------------------------------------

TTI GmbH - TGU scireum, Friedrichstr. 8, 70736 Fellbach

Tel: (0711) 69394632  -  E-Mail:   address@hidden
Fax: (0711) 69394635  -  Internet: http://www.scireum.de

 

TTI GmbH - Zentrale, Nobelstr. 15, 70569 Stuttgart

Geschäftsführer: Prof. Dr.-Ing. Bernd Bertsche, Elgar Rödler

Amtsgericht Stuttgart, HRB 19455

 

From: Pratyus Patnaik [mailto:address@hidden
Sent: Thursday, August 20, 2009 10:45 AM
To: address@hidden
Subject: Re: [Swftools-common] Text search in SWF

 

I used the the swf file you had sent me (aha_1.swf). It still gave me the same error. Failed search and returned 0 for snapText.charCount.toString().
Can this be because of flex version? I am using flex 3. Also, I run my viewer on windows XP (after converting pdf2swf in redhat), I am again attaching the exact code along with the swf generated for it.

Thanks again.

On Thu, Aug 20, 2009 at 1:30 AM, Pratyus Patnaik <address@hidden> wrote:

Hey Andy,

thanks a lot for the help.
My pdf2swf version is 0.8.1 probably this is the problem. Its getting too late in california, So I will install the rpm tomorrow and check if it works.
I think this (http://packman.links2linux.org/package/swftools) rpm should work. If not, will it be possible for you send me your rpm package?

Have a good day.


Thanks a lot again,
regards
Pratyus

On Thu, Aug 20, 2009 at 1:19 AM, Andreas Haufler (scireum) <address@hidden> wrote:

Hey there,

 

are you using pdftools 0.9.0? Check via: pdf2swf --version

 

A attached the converted SWF which works fine with our viewer. The SWF you supplied did not work L.

 

If the problem persists (you need pdf2swf 0.9.0), feel free to ask again.

 

Best regards

Andy

 

 

freundliche Grüße
scireum - Ein Unternehmen der TTI GmbH

i.A. Andreas Haufler
Projektleiter scireum

-------------------------------------------------------------------------------------------------------

TTI GmbH - TGU scireum, Friedrichstr. 8, 70736 Fellbach

Tel: (0711) 69394632  -  E-Mail:   address@hidden
Fax: (0711) 69394635  -  Internet: http://www.scireum.de

 

TTI GmbH - Zentrale, Nobelstr. 15, 70569 Stuttgart

Geschäftsführer: Prof. Dr.-Ing. Bernd Bertsche, Elgar Rödler

Amtsgericht Stuttgart, HRB 19455

 

From: Pratyus Patnaik [mailto:address@hidden]
Sent: Thursday, August 20, 2009 9:50 AM
To: address@hidden
Cc: address@hidden
Subject: Re: [Swftools-common] Text search in SWF

 

Thanks, but the search still fails :(

infact when i do the the following:

private function doSearch() : void
                {
                snapText = img.textSnapshot;
                Alert.show(snapText.charCount.toString());     (---> this returns a 0, the snapText does not seem to load any texts...)
                if (SearchInpt.text != '' && SearchInpt.text.length > 1) {

Is there something else I might be missing. Is there a way around this, or a better way to do it?
I have attached the pdf and swf (after converting using pdf2swf -f  -T 9 in.pdf --output testswf2.swf). Is it possible that my test files have something wrong?

Thanks a lot again,

regards,
Pratyus

On Wed, Aug 19, 2009 at 11:28 PM, Andreas Haufler (scireum) <address@hidden> wrote:

 

 

freundliche Grüße
scireum - Ein Unternehmen der TTI GmbH

i.A. Andreas Haufler
Projektleiter scireum

-------------------------------------------------------------------------------------------------------

TTI GmbH - TGU scireum, Friedrichstr. 8, 70736 Fellbach

Tel: (0711) 69394632  -  E-Mail:   address@hidden
Fax: (0711) 69394635  -  Internet: http://www.scireum.de

 

TTI GmbH - Zentrale, Nobelstr. 15, 70569 Stuttgart

Geschäftsführer: Prof. Dr.-Ing. Bernd Bertsche, Elgar Rödler

Amtsgericht Stuttgart, HRB 19455

 

From: Andreas Haufler (scireum) [mailto:address@hidden]
Sent: Thursday, August 20, 2009 8:13 AM
To: 'Pratyus Patnaik'
Subject: RE: [Swftools-common] Text search in SWF

 

Hi Pratyus,

 

you probably want to add the option –T 9 which sets the player version of the resulting swf to 9. This changes the way, the swf is loaded by your flex application and permits to use TextSnapshot. You also should keep the instance of TextSnapshot in a variable which is only filled once after the file was loaded, otherwise some strange errors might occur.

 

Example command:

 

pdf2swf -f  -T 9 in.pdf --output out.swf

 

best regards

Andy

 

 

freundliche Grüße
scireum - Ein Unternehmen der
TTI GmbH

i.A. Andreas Haufler
Projektleiter scireum

-------------------------------------------------------------------------------------------------------

TTI GmbH - TGU scireum, Friedrichstr. 8, 70736 Fellbach

Tel: (0711) 69394632  -  E-Mail:   address@hidden
Fax: (0711) 69394635  -  Internet: http://www.scireum.de

 

TTI GmbH - Zentrale, Nobelstr. 15, 70569 Stuttgart

Geschäftsführer: Prof. Dr.-Ing. Bernd Bertsche, Elgar Rödler

Amtsgericht Stuttgart, HRB 19455

 

From: swftools-common-bounces+aha=scireum.de@nongnu.org [mailto:swftools-common-bounces+aha=scireum.de@nongnu.org] On Behalf Of Pratyus Patnaik
Sent: Wednesday, August 19, 2009 11:33 PM
To: address@hidden
Subject: [Swftools-common] Text search in SWF

 

I trying to build a simple application in flex in which I render a swf in the application. I want to enable user to search text using a textbox (id="SearchInpt") and button (id="SearchBtn").

I used this following command to convert the pdf to swf
 pdf2swf -f file.pdf -o file.swf   (thanks Matthias)

I am able to load the swf file into the application, but search always fails. Below is the code I am using (source: http://wiki.swftools.org/index.php/How_do_I_highlight_text_in_the_SWF%3F).

Am I missing something in the code. I will be grateful for any help or pointers to resources.
 
Thanks!

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
   
   
    <mx:Script>
        <![CDATA[
          
            import mx.controls.SWFLoader;
            import mx.controls.Label;
            import flash.text.TextSnapshot;
           
           public var snapText:TextSnapshot;
                      
            private function doSearch() : void 
                {
                snapText = img.textSnapshot;
                if (SearchInpt.text != '' && SearchInpt.text.length > 1) {
                        var textPos:int = snapText.findText(0, SearchInpt.text, false);
                        snapText.setSelected( 0, snapText.charCount, false );
       
                if (textPos > 0) {
                    do {
                        snapText.setSelectColor( 0xFFEF00 );
                        snapText.setSelected( textPos, textPos + SearchInpt.text.length, true );
                         textPos = snapText.findText(textPos + SearchInpt.text.length, SearchInpt.text, false);
                        }
                    while (textPos > 0)
                    }
                else
                    {
                    Alert.show( "Not found.", "Information" );                
                    }
                }
                else
                    {
                    snapText.setSelected( 0, snapText.charCount, false );                   
                    }

                }
        ]]>
    </mx:Script>
       
        <mx:Panel title="SWF Player" y = "50" width="100%" height="100%">
             <mx:Canvas id="canvas" width="100%" height="100%">
                   <mx:TextInput x="10" y="21" width="80" id="SearchInpt"/>
                   <mx:Button x="98" y="21" label="Search" id="SearchBtn" click = "doSearch()"/>
                   <mx:SWFLoader id ="img" source="C:/file.swf" y="50" />
             </mx:Canvas>
     </mx:Panel>
</mx:Application>

 

 

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]