[Top][All Lists]

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

[Swftools-common] pdf2swf: lineheight tends to be overestimated for text

From: Matt Long
Subject: [Swftools-common] pdf2swf: lineheight tends to be overestimated for text
Date: Wed, 3 Jun 2009 15:34:05 -0400


After converting a PDF using the following command with version 0.9 of pdf2swf, the reported height of text characters tends to be to tall.

pdf2swf --fonts --stop --flashversion 9 input.pdf -o output.swf

I'm writing my own viewer that allows the user to select/highlight text on the pdf as you would on any text editor/web browser.

The relevant steps to get to the point of highlighting text are:

//load the SWF of the PDF...
var loader = new SWFLoader();
this.loader.addEventListener(Event.INIT, onContentLoaded);
this.loader.load(bytes); //assume bytes is a byte array that contains the binary data of the swf I'm trying to view

//after it's loaded, get the MovieClip object
function onContentLoaded(e:Event):void {
mc = MovieClip(loader.content);

//select text by character index when the mouse button is held down and over characters
mc.textSnapshot.setSelected(startIndex, endIndex, true);

After converting and loading the PDF at http://web.mit.edu/mattlong/Public/pdf2swfstuff/report.pdf in this fashion, if you try to select any of the text from the first page (I've provided start and end character indexes for each line here)

June 2007  (125 - 133)
Report to Congress  (135 - 152)
In accordance with the  (154 - 175)
Department of Defense Appropriations Act 2007  (177 - 221)
(Section 9010, Public Law 109-289)  (223 - 256)

you see that the highlight extends nearly twice as high as the actual characters and perhaps half the character height below the character. Take a look at the screenshot at http://imgur.com/K8EUq.png to see what I'm talking about.

Is this a bug in pdf2swf?  Is there a smarter way to highlight text in the SWF that will have a more accurate line height? Any advice or suggestions are welcome!

Thanks in advance!

Matt Long
Lead Developer

reply via email to

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