1

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.

Raghu
  • 45
  • 1
  • 8

3 Answers3

3

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");
Ryan Taylor
  • 8,740
  • 15
  • 65
  • 98
splash
  • 13,037
  • 1
  • 44
  • 67
1

Try this

var pdfFile:PDF = new PDF();
var pdfByteArray:ByteArray =  new ByteArray ();
pdfByteArray = pdfFile.save(Method.LOCAL);
McDowell
  • 107,573
  • 31
  • 204
  • 267
Nidhi
  • 755
  • 3
  • 11
  • 25
  • This only generates the bytes for the PDF. It doesn't actually prompt the user where to save it to disk as asked. –  Apr 03 '13 at 17:28
0

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");
Yannick Chaze
  • 576
  • 6
  • 17