2
votes

I need to export charts and data tables to pdf file in flex application.

For this we can user AlivePDF but i need to export to local not server.

Can we export to local system prompting user to select the location to export?

Thanks in advance.

3

3 Answers

4
votes

Since FP10 the FileReference Class should support this via the save() function. The code to do this in Flash Player 10 or better is shown below:

var bytes:ByteArray = pdf.save(Method.LOCAL);
var file:FileReference = new FileReference();
file.save(bytes, "myPDF.pdf");
1
votes

Try this

var pdfFile:PDF = new PDF();
var pdfByteArray:ByteArray =  new ByteArray ();
pdfByteArray = pdfFile.save(Method.LOCAL);
1
votes

With the latest version of AlivePDF (0.1.5 RC), you can do this:

var element:IBitmapDrawable; // Chart to export
var pdf:PDF = new UnicodePDF();
pdf.addPage();

var bitmapData:BitmapData = new BitmapData(element.width, element.height, false, 0xffffff);
try{
    bitmapData.draw(element as IBitmapDrawable);
}catch(e:*)
{
    throw new Error("bitmap draw failed");
}

var jpegencoder:JPEGEncoder = new JPEGEncoder(100);
var byteArray:ByteArray     = jpegencoder.encode(bitmapData);

pdf.addImageStream(byteArray);
var file : FileReference = new FileReference()
file.save(pdf.save(Method.LOCAL),"my.pdf");