On Thu, 13 Nov 2008 17:01:28 GMT,

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

>On Thu, 13 Nov 2008 03:46:12 -0800 (PST), Bill H <(E-Mail Removed)> wrote:

>

>>I have been trying to figure out how to do this in perl for weeks and

>>justcan't seem to fingure it out. I can see it in my mind how it

>>should work.

>>

>>The problem I have is this. I have a flash interface that sends perl

>>some image coordinates that perl then uses to make pdf's using

>>pdf:api2. In flash I use the standard coordinate system:

>>

>>0,0------------------> X

>>|

>>|

>>|

>>v

>>Y

>>

>>(ie x,y is starts at top left corner). So I will send the perl program

>>a image coordinate in the format of x,y,width,height.

>>

>>Now on the prl side, making the pdf the coordinate system is:

>>

>>Y

>>|

>>|

>>|

>>|

>>0,0 ------------------> X

>>

>>(ie x,y starts at bottom left corner) and I need to translate the

>>flash coordinates to the perl / pdf coordinates.

>>

>>So, if I have a page that is 5 1/2" x 8 1/2" inches, or 396 x 612

>>(using 72dpi) and I am placing a 1" x 1" image at 1" x 1" (x,y = 72,72

>>in flash and width = 72, and height = 72) then my x,y coordinates in

>>perl whould be 72,540.

>>

>>The problem I have is, trying to come up with a algorythm that will

>>translate the one set of coordinates into the other.

>>

>>I hope I am making sense.

>>

>>Bill H

>

>I don't know why you try to obfucate the issue with

>> ... and I am placing a 1" x 1" image at 1" x 1"

>Whats that all about?

>

>You can do something complicated like this:

>

>sln

>----------------------------

>

>use strict;

>use warnings;

>

>sub ConvertInchesToDots

>{

> my ($dpi, $inchref) = @_;

> my @dots = ();

> for (@$inchref) {

> push @dots, ($_ * $dpi);
^^^^^^^^^^^

push @dots, (int(($_ * $dpi)+.5));

Forgot this. This will round then convert fractional inches to integer dots

> }

> return \@dots;

>}

>sub FlashToPdfCoords

>{

> my ($dpi, $refFlashCoords) = @_;

> my $refpdfcoords = ConvertInchesToDots ($dpi, $refFlashCoords);

> $refpdfcoords->[1] = $refpdfcoords->[3] - $refpdfcoords->[1]; # pdfY = dpi * (flashH - flashY)

> return @$refpdfcoords;

>}

>

>

>my @Flashcoords = (1, 1, 5.5, 8.5); # x,y,width,height

>my @Pdfcoords = FlashToPdfCoords (72, \@Flashcoords);

>

>print "\nPdf ( X, Y, Width, Heigth ) = Flash ( X, Y, Width, Heigth )\n";

>print "Pdf (@Pdfcoords) = Flash (@Flashcoords)\n";

>

>

>__END__

>

>

>Pdf ( X, Y, Width, Heigth ) = Flash ( X, Y, Width, Heigth )

>Pdf (72 540 396 612) = Flash (1 1 5.5 8.5)

>