[haXe] pdf generation with alivepdf & haxe
Nicolas Cannasse
ncannasse at motion-twin.com
Tue Dec 4 10:10:27 CET 2007
Glen Blanchard a écrit :
> Just looking at it quickly, if you are running swhx then this is
> fairly easy to do.
Hi,
Yes, there's two possibilities for doing what Jan is needing :
a) build a SWHX application, with a haXe/Neko part that save the file on
disk and an AS3 SWF that will create the PDF. This is easy to do but not
very nice to maintain since the app is separated into two components
while this is not very useful in your case.
b) port alivePDF first to haXe/Flash9, then write a small abstraction of
ByteArray to neko (which will output to a neko.io.Ouput) in order to be
able to compile the library directly to haXe/Neko and run it from
commandline (without using SHWX or Flash Player). This will be a lot
more lightweight solution but require more development.
Although I'm a SWHX co-author, I would personally go for (b) :) I think
such work could also be released through haxelib (http://lib.haxe.org)
in order to be reused and improved by the whole haXe community.
> Haxe:
>
> // create window/remoting server/flash instance
> var pdf = flash.generatePDF.call([]);
> var output = neko.io.File.write("mypdf.pdf", true);
> output.writeBytes(pdf.join(""));
> output.close();
>
> The only problems you may run into is converting the ByteArray to a
> string for writeBytes.
>
> Either do it in haxe using above method of pdf.join("") or do in in
> flash using ByteArray.toString();
Flash9 ByteArrays are directly serialized to binary neko strings by
haxe.Serializer, so you can directly send binary data from the Flash
layer to the Neko one (the other way is not supported because Neko
doesn't have a ByteArray class, since Strings are already byte arrays).
Best,
Nicolas
More information about the Haxe
mailing list