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:   [email protected]
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:[email protected]] 
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:   [email protected]
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: [email protected]
[mailto:[email protected]] On Behalf Of
Pratyus Patnaik
Sent: Wednesday, August 19, 2009 11:33 PM
To: [email protected]
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