2

I have a large web application with verticalScrollBar with few charts and large datagrid. I am planning to create pdf of my web application using AlivePdf.

Right now, Im using below code to creat a pdf of my application, but no luck.

        var printView:DisplayObject  = new InteractionsAnalysis() as DisplayObject;
        printView.width = Application.application.width;
        printView.height = Application.application.height;          

    var printPDF:PDF = new PDF(Orientation.PORTRAIT, Unit.MM, Size.A4);
    printPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
    printPDF.addPage();
    printPDF.addImage(printView,0,0,0,0,"PNG",100,1,ResizeMode.FIT_TO_PAGE);

   var f:FileReference = new FileReference();
   var b:ByteArray = printPDF.save(Method.LOCAL);
   f.save(b);

Can anybody give me some directions?

splash
  • 13,037
  • 1
  • 44
  • 67
sanjeev
  • 74
  • 5

1 Answers1

1

Verify that the method which is calling f.save() was triggered due from a user event. According to the FileReference doc:

In Flash Player, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception. This limitation does not apply to AIR content in the application sandbox.

James Ward
  • 29,283
  • 9
  • 49
  • 85