Re: [Swftools-common] PDF2SWF and getTextSnapShot()

2007-11-21 Thread Jörg Birkhold

Hello,

simple Question:
Did anybody manage to select text with gettextsnapshot in a flash9 / 
flex file? if yes how?
i can't get it to work. i can get the textsnapshot and search/find the 
text but it doesn't highlight :-(.


best regards

joerg



Mark A. Lowe schrieb:

Hey Jan,

I've uploaded a sample to :
http://www.multimediaresourceaustralia.com/~temp/pdf2swf/searchTextSample.zi
p
It contains my working PDF file, outputted SWF file, and a flash8 (and Flash
CS3) FLA which loads the SWF and has the Search Text button with the hltext
function on it.
There are some instructions in the .txt file.

Hope this helps!


mark lowe
senior multimedia developer
multimedia resource australia
t:
+61 3 9602 4750 
f:
+61 3 9606 0408 
e:

[EMAIL PROTECTED]
w:
www.mmr.com.au
level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]
p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

-Original Message-
From: jan bahnsen [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 16, 2007 12:19 AM

To: Mark A. Lowe
Subject: Re: [Swftools-common] PDF2SWF and getTextSnapShot()

Hi Mark,

great stuff!

  

If anyone would like some sample files give me a shout,



Would really appreciate if you could pop over a sample - will be very
useful for better understanding!

Cheers, Jan.



2007/11/15, Mark A. Lowe [EMAIL PROTECTED]:
  

Many thanks Fabio,
I've managed to get somewhere with your actionscript.
I also had a problem with how I was creating my swf from pdf2swf.

For everyone else make sure you follow these steps:

1. Use Flash 8 or previous version (I used 6) with the -T command :


pdf2swf -T 6
  

2. Use the -f command for full fonts : pdf2swf -f
3. Test your outputted swf with: swfdump -t filename.swf , you should see


a list of DEFINETEXT statements and the corresponding text. Due to a font
conflict I was seeing DEFINETEXT followed by jumbled up text on my first
pdf.
  

4. Test your outputted swf with: swfstrings filename.swf, you should see


your text and a LOT of ???s. Again, I had garbage text when trying to
convert my original PDF.
  

If the swfdump and swfstrings tests are working, load your pdf2swf.swf


into Flash. Publish it for 8.
  

I loaded it into a movieclip on my root timeline called 'loader' :


loader.loadMovie(pdf2swf_files/6new.swf);
  

I have a movieclip called 'searchText_mc' and have the following code for


it:
  

searchText_mc.onRelease = function() {
   hltext (wonderful);
}

And then the hltext is as Fabio provided. This will yellow-highlight all


the occurrences of the search string:
  

function hltext ( txt )
{
   trace(hltext);
   var mc = _root.loader;
   var my_snap:TextSnapshot = mc.getTextSnapshot();
   var start_pos:Number = 0;

   start_pos = my_snap.findText ( start_pos, txt, false );
   trace(start_pos :  + start_pos);
   while ( start_pos  0 )
   {
   trace ( start_pos );
   my_snap.setSelected( start_pos, start_pos +


txt.length, true );
  

   start_pos += txt.length;
   start_pos = my_snap.findText ( start_pos, txt,


false );
  

   }

}

If anyone would like some sample files give me a shout,



mark lowe
senior multimedia developer
multimedia resource australia
t:
+61 3 9602 4750
f:
+61 3 9606 0408
e:
[EMAIL PROTECTED]
w:
www.mmr.com.au
level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]
p.o. box 205, fitzroy vic 3065 [ all other correspondence ]


-Original Message-
From: [EMAIL PROTECTED]


[mailto:[EMAIL PROTECTED] On Behalf Of
Fabio Rotondo
  

Sent: Wednesday, November 14, 2007 8:39 PM
To: swftools-common@nongnu.org
Subject: Re: [Swftools-common] PDF2SWF and getTextSnapShot()

Mark A. Lowe wrote:

Hi Mark,



I'm still learning it and the answer may be obvious, but where would I
find some documentation/examples on how to search the text once I have
loaded my (pdf2swf) .swf file into my Flash application?


this is a common question. You should have had a look to the mailing
list archives before asking  ;-)

that said, here there is my ActionScript code to highlight the text
inside a PDF page. It works with Flash 8 or previous ONLY because the
new Flash 9 has a different AVM interpreter (AVM2) and many things have
changed.

Please note:

- ``txt`` is the text to search and highlight inside your page
- ``mc`` points to _root.text that's where I was keeping my swf/pdf page
you should change that so it references yours.

Here is the code:

function hltext ( txt )
{
   var mc = _root.text;
   var my_snap:TextSnapshot = mc.getTextSnapshot();
   var start_pos:Number = 0;

   start_pos = my_snap.findText ( start_pos, txt, false );

   while ( start_pos  0 )
   {
   trace ( start_pos );
   my_snap.setSelected( start_pos, start_pos +


txt.length, true

Re: [Swftools-common] PDF2SWF and getTextSnapShot()

2007-11-21 Thread Fabio Rotondo
Jörg Birkhold wrote:

Hi,

the problem is that Flash 9 has a different Virtual Machine (AVM2)
and that (at the moment) SWFTools is not able to output valid AVM2
code.
Stay tuned, we are working on it right now :-)

Ciao,

Fabio

 Hello,
 
 simple Question:
 Did anybody manage to select text with gettextsnapshot in a flash9 /
 flex file? if yes how?
 i can't get it to work. i can get the textsnapshot and search/find the
 text but it doesn't highlight :-(.
 
 best regards
 
 joerg




RE: [Swftools-common] PDF2SWF and getTextSnapShot()

2007-11-15 Thread Mark A. Lowe
Hey Jan,

I've uploaded a sample to :
http://www.multimediaresourceaustralia.com/~temp/pdf2swf/searchTextSample.zi
p
It contains my working PDF file, outputted SWF file, and a flash8 (and Flash
CS3) FLA which loads the SWF and has the Search Text button with the hltext
function on it.
There are some instructions in the .txt file.

Hope this helps!


mark lowe
senior multimedia developer
multimedia resource australia
t:
+61 3 9602 4750 
f:
+61 3 9606 0408 
e:
[EMAIL PROTECTED]
w:
www.mmr.com.au
level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]
p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

-Original Message-
From: jan bahnsen [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 16, 2007 12:19 AM
To: Mark A. Lowe
Subject: Re: [Swftools-common] PDF2SWF and getTextSnapShot()

Hi Mark,

great stuff!

 If anyone would like some sample files give me a shout,

Would really appreciate if you could pop over a sample - will be very
useful for better understanding!

Cheers, Jan.



2007/11/15, Mark A. Lowe [EMAIL PROTECTED]:
 Many thanks Fabio,
 I've managed to get somewhere with your actionscript.
 I also had a problem with how I was creating my swf from pdf2swf.

 For everyone else make sure you follow these steps:

 1. Use Flash 8 or previous version (I used 6) with the -T command :
pdf2swf -T 6
 2. Use the -f command for full fonts : pdf2swf -f
 3. Test your outputted swf with: swfdump -t filename.swf , you should see
a list of DEFINETEXT statements and the corresponding text. Due to a font
conflict I was seeing DEFINETEXT followed by jumbled up text on my first
pdf.
 4. Test your outputted swf with: swfstrings filename.swf, you should see
your text and a LOT of ???s. Again, I had garbage text when trying to
convert my original PDF.

 If the swfdump and swfstrings tests are working, load your pdf2swf.swf
into Flash. Publish it for 8.
 I loaded it into a movieclip on my root timeline called 'loader' :
loader.loadMovie(pdf2swf_files/6new.swf);
 I have a movieclip called 'searchText_mc' and have the following code for
it:

 searchText_mc.onRelease = function() {
hltext (wonderful);
 }

 And then the hltext is as Fabio provided. This will yellow-highlight all
the occurrences of the search string:

 function hltext ( txt )
 {
trace(hltext);
var mc = _root.loader;
var my_snap:TextSnapshot = mc.getTextSnapshot();
var start_pos:Number = 0;

start_pos = my_snap.findText ( start_pos, txt, false );
trace(start_pos :  + start_pos);
while ( start_pos  0 )
{
trace ( start_pos );
my_snap.setSelected( start_pos, start_pos +
txt.length, true );
start_pos += txt.length;
start_pos = my_snap.findText ( start_pos, txt,
false );
}

 }

 If anyone would like some sample files give me a shout,



 mark lowe
 senior multimedia developer
 multimedia resource australia
 t:
 +61 3 9602 4750
 f:
 +61 3 9606 0408
 e:
 [EMAIL PROTECTED]
 w:
 www.mmr.com.au
 level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]
 p.o. box 205, fitzroy vic 3065 [ all other correspondence ]


 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Fabio Rotondo
 Sent: Wednesday, November 14, 2007 8:39 PM
 To: swftools-common@nongnu.org
 Subject: Re: [Swftools-common] PDF2SWF and getTextSnapShot()

 Mark A. Lowe wrote:

 Hi Mark,

   I'm still learning it and the answer may be obvious, but where would I
   find some documentation/examples on how to search the text once I have
   loaded my (pdf2swf) .swf file into my Flash application?

 this is a common question. You should have had a look to the mailing
 list archives before asking  ;-)

 that said, here there is my ActionScript code to highlight the text
 inside a PDF page. It works with Flash 8 or previous ONLY because the
 new Flash 9 has a different AVM interpreter (AVM2) and many things have
 changed.

 Please note:

 - ``txt`` is the text to search and highlight inside your page
 - ``mc`` points to _root.text that's where I was keeping my swf/pdf page
 you should change that so it references yours.

 Here is the code:

 function hltext ( txt )
 {
var mc = _root.text;
var my_snap:TextSnapshot = mc.getTextSnapshot();
var start_pos:Number = 0;

start_pos = my_snap.findText ( start_pos, txt, false );

while ( start_pos  0 )
{
trace ( start_pos );
my_snap.setSelected( start_pos, start_pos +
txt.length, true );
start_pos += txt.length;
start_pos = my_snap.findText ( start_pos, txt,
false );
}

 }


 Have fun!

 Ciao,
 Fabio









Re: [Swftools-common] PDF2SWF and getTextSnapShot()

2007-11-14 Thread Pete Siviter

Hi Mark,

You are right about the SWF strings program, there appear to be issues 
with some pdfs.  When I tried it initially, I got sensible output from 
the swfs I was trying.  I've checked a couple more and am getting the 
???'s you described on most of them.  Another suggestion is the PDF 
version causing issues?  I know some mags here are produced from Acrobat 
5 and some Acrobat 8...


So I guess I may look at extracting strings earlier in the process from 
the PDFs if I can.  Like I said, the intention is to get to the right 
page using this technique and then highlight the words on the page.


If I can find any clues about how to search a page and highlight words 
I'll let you know too.  I'm using Flex to embed the SWF's inside my 
master movie (using a class derived from SWFLoader) so I am almost 
certainly looking for the same thing you are.


Cheers,
Pete


Mark A. Lowe wrote:


Hey Pete,

 

Thanks for your response. I hadn't actually seen the swfstrings 
command before.


I've tried it out on some of my pdf2swf swfs and all I get is a load 
of ??? outputted.


I'm guessing this has something to do with a font issue maybe?

 

Your process is interesting and could work somewhat. However, I am 
very keen to highlight the search words.


I've seen this done on some e-mag sites and am pretty certain they are 
using a combination of pdf2swf and getTextSnapShot().


 


I'll keep searching and let you know if I come across anything,

 


Thanks again, Mark.

 




*mark lowe*
senior multimedia developer

*multimedia resource australia*

*t:*



+61 3 9602 4750

*f:*



+61 3 9606 0408

*e:*



[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

*w:*



www.mmr.com.au http://www.mmr.com.au

level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]

p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

 


*From:* Pete Siviter [mailto:[EMAIL PROTECTED]
*Sent:* Tuesday, November 13, 2007 7:50 PM
*To:* Mark A. Lowe
*Subject:* Re: [Swftools-common] PDF2SWF and getTextSnapShot()

 


Hi Mark,

I am probably walking a similar road to you at the moment and, 
although I haven't done it yet, my next planned step was to use the 
swfstrings program  to fill a MySQL database with words tied to the 
specific swf files.


I am using a php script to convert my thousands of pdfs to swfs so it 
is an easy step to catch the output from swfstrings on the converted 
pages and put it in a database.


After this you can query the mysql database to locate swf files with 
specific words and therefore know what page to go to.


This works for me because every page is a separate swf file with the 
page number in it's name.  You could produce a database from a split 
pdf file converted using  a splitting utility (like gios splitter), 
convert those to swf files (via qpdf2swf) and then use swfstrings...  
If that works for you...


There's probably a way of doing it directly from the pdf though.

That gets you to a particular page.  As far as highlighting the 
specific search words on the page?  No idea at this stage.


Cheers,
Pete



Mark A. Lowe wrote:

Hey guys,

 


Just starting to use PDF2SWF for my e-mag system and it's working great.

I'm still learning it and the answer may be obvious, but where would I 
find some documentation/examples on how to search the text once I have 
loaded my (pdf2swf) .swf file into my Flash application?


Is all the text put in a specified textfield, or is it broken up into 
multiple fields?


Any guidance would be greatly appreciated,

 


Mark.

 




*mark lowe*
senior multimedia developer

*multimedia resource australia*

*t:*



+61 3 9602 4750

*f:*



+61 3 9606 0408

*e:*



[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

*w:*



www.mmr.com.au http://www.mmr.com.au

level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]

p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

 

 

This message has been scanned by MailController 
http://www.mailcontroller.altohiway.com/.




Re: [Swftools-common] PDF2SWF and getTextSnapShot() (sent to wrong address - apologies)

2007-11-14 Thread Pete Siviter

Hi Mark,

I am probably walking a similar road to you at the moment and, although 
I haven't done it yet, my next planned step was to use the swfstrings 
program  to fill a MySQL database with words tied to the specific swf files.


I am using a php script to convert my thousands of pdfs to swfs so it is 
an easy step to catch the output from swfstrings on the converted pages 
and put it in a database.


After this you can query the mysql database to locate swf files with 
specific words and therefore know what page to go to.


This works for me because every page is a separate swf file with the 
page number in it's name.  You could produce a database from a split pdf 
file converted using  a splitting utility (like gios splitter), convert 
those to swf files (via qpdf2swf) and then use swfstrings...  If that 
works for you...


There's probably a way of doing it directly from the pdf though.

That gets you to a particular page.  As far as highlighting the specific 
search words on the page?  No idea at this stage.


Cheers,
Pete



Mark A. Lowe wrote:


Hey guys,

 


Just starting to use PDF2SWF for my e-mag system and it's working great.

I'm still learning it and the answer may be obvious, but where would I 
find some documentation/examples on how to search the text once I have 
loaded my (pdf2swf) .swf file into my Flash application?


Is all the text put in a specified textfield, or is it broken up into 
multiple fields?


Any guidance would be greatly appreciated,

 


Mark.

 




*mark lowe*
senior multimedia developer

*multimedia resource australia*

*t:*



+61 3 9602 4750

*f:*



+61 3 9606 0408

*e:*



[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

*w:*



www.mmr.com.au http://www.mmr.com.au

level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]

p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

 




This message has been scanned by MailController 
http://www.mailcontroller.altohiway.com/.




Re: [Swftools-common] PDF2SWF and getTextSnapShot()

2007-11-14 Thread Fabio Rotondo
Mark A. Lowe wrote:

Hi Mark,

  I’m still learning it and the answer may be obvious, but where would I
  find some documentation/examples on how to search the text once I have
  loaded my (pdf2swf) .swf file into my Flash application?

this is a common question. You should have had a look to the mailing
list archives before asking  ;-)

that said, here there is my ActionScript code to highlight the text
inside a PDF page. It works with Flash 8 or previous ONLY because the
new Flash 9 has a different AVM interpreter (AVM2) and many things have
changed.

Please note:

- ``txt`` is the text to search and highlight inside your page
- ``mc`` points to _root.text that's where I was keeping my swf/pdf page
 you should change that so it references yours.

Here is the code:

function hltext ( txt )
{
var mc = _root.text;
var my_snap:TextSnapshot = mc.getTextSnapshot();
var start_pos:Number = 0;

start_pos = my_snap.findText ( start_pos, txt, false );

while ( start_pos  0 )
{
trace ( start_pos );
my_snap.setSelected( start_pos, start_pos + txt.length, 
true );
start_pos += txt.length;
start_pos = my_snap.findText ( start_pos, txt, false );
}

}


Have fun!

Ciao,
Fabio





RE: [Swftools-common] PDF2SWF and getTextSnapShot()

2007-11-13 Thread Mark A. Lowe
Hey Pete,

 

Thanks for your response. I hadn't actually seen the swfstrings command
before.

I've tried it out on some of my pdf2swf swfs and all I get is a load of
??? outputted.

I'm guessing this has something to do with a font issue maybe?

 

Your process is interesting and could work somewhat. However, I am very keen
to highlight the search words.

I've seen this done on some e-mag sites and am pretty certain they are using
a combination of pdf2swf and getTextSnapShot().

 

I'll keep searching and let you know if I come across anything,

 

Thanks again, Mark.

 

  _  


mark lowe
senior multimedia developer


multimedia resource australia


t:

+61 3 9602 4750 


f:

+61 3 9606 0408 


e:

 mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]


w:

 http://www.mmr.com.au www.mmr.com.au

level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]

p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

 

From: Pete Siviter [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 13, 2007 7:50 PM
To: Mark A. Lowe
Subject: Re: [Swftools-common] PDF2SWF and getTextSnapShot()

 

Hi Mark,

I am probably walking a similar road to you at the moment and, although I
haven't done it yet, my next planned step was to use the swfstrings program
to fill a MySQL database with words tied to the specific swf files.

I am using a php script to convert my thousands of pdfs to swfs so it is an
easy step to catch the output from swfstrings on the converted pages and put
it in a database.

After this you can query the mysql database to locate swf files with
specific words and therefore know what page to go to.

This works for me because every page is a separate swf file with the page
number in it's name.  You could produce a database from a split pdf file
converted using  a splitting utility (like gios splitter), convert those to
swf files (via qpdf2swf) and then use swfstrings...  If that works for
you...

There's probably a way of doing it directly from the pdf though.

That gets you to a particular page.  As far as highlighting the specific
search words on the page?  No idea at this stage.

Cheers,
Pete



Mark A. Lowe wrote: 

Hey guys,

 

Just starting to use PDF2SWF for my e-mag system and it's working great.

I'm still learning it and the answer may be obvious, but where would I find
some documentation/examples on how to search the text once I have loaded my
(pdf2swf) .swf file into my Flash application?

Is all the text put in a specified textfield, or is it broken up into
multiple fields?

Any guidance would be greatly appreciated,

 

Mark. 

 

  _  


mark lowe
senior multimedia developer


multimedia resource australia


t:

+61 3 9602 4750 


f:

+61 3 9606 0408 


e:

 mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]


w:

 http://www.mmr.com.au www.mmr.com.au

level 2, 351 elizabeth st, melbourne vic 3000  [ courier correspondence ]

p.o. box 205, fitzroy vic 3065 [ all other correspondence ]

 

 

This message has been scanned by MailController
http://www.mailcontroller.altohiway.com/ .