I has taken almost 4 months for me to have enough time to circle back and take a look at this issue in detail.
With swf version 9 onward flash requires that an embedded have its optional layout defined. Without the layout object the following flash functions will not work properly: TextSnapshot.hitTextTextNearPos() -- will never find text and only return -1 TextSnapshot.getTextRunInfo() -- specifically the corner#x and corner#y properties will not be populated These functions are very important for allowing a user to interact with static text on the page. By default the pdf2swf system will remove the layout from fonts, which is probably a bug, actually 2 bugs, which I will document further in another email. One bug is very easy to work around. If one calls pdf2swf with the following command-line parameter it will force swftools to skip the font reduction step and preserve most of the font layout information. pdf2swf [...] --set storeallcharacters="1" ~Ken Sturgis From: Denis Zgonjanin Sent: Sunday, February 21, 2010 12:31 PM To: [email protected] Subject: Re: [Swftools-common] Text Selection and other questions Has anyone looked into this since the post was made? On Thu, Feb 4, 2010 at 12:30 PM, <[email protected]> wrote: I just started looking at using swfTools to convert PDF documents to flash AS3 files and I ran into this same problem. This problem is actually causing me a bit of pain. I know what is causing this problem which I will discuss below. I have spent only about an hour looking at the swfTools code and can't pin point exactly where the problem is in the code, but maybe someone else on this mailing list will know exactly where the problem is and know how to easily fix it. The problem is the output SWF file is missing the FontBoundsTable in the DefineFont2 tag. The flash specification for flash 6 included this table that defines the area of each of the glyphs in the font table. However, this table was not used in the flash 6 player. So if you are output a flash 6 file there is no reason to include the bounds table. Flash 6 dynamically generates this bound information. However flash 9 (AVM2) works differently without this bounding table information the fonts will still display, but when you call getTextRunInfo() the returned object will be missing the corner information (i.e.corner0x). I can see in the code that the FontBoundsTable is being populated ( SWF_Font->layout->bounds ). But maybe it isn't being saved to the output file? I haven't managed to track down where the save routines are in the code yet. If anyone has any comments it would be greatly appreciated. Ken Sturgis > Re: [Swftools-common] Text Selection and other questions > Denis Zgonjanin > Thu, 14 Jan 2010 14:02:56 -0800 > Hi Filip, > > Thanks for the answers. I did try drawing shapes around the individual > characters, but have another problem. getTextRun() returns to me the x and y > position of the character, but height is returned as a decimal between 0 and > 1, which is odd because height is supposed to be in pixels. Also parameters > corner0x, corner0y, corner1x, corner1y, etc... are not there at all. The > documentation for getTextRun says that these will only be available if the > font is embedded in the SWF file. When I convert the file with pdf2swf I > include my entire fonts directory, yet even with simple fonts I don't seem > to be able to get these parameters. Do I have to explicitelly embed that > font in AS3 as well? If so, how do I know which fonts are in the pdf > originally? > > Thanks, > - Denis
