How to create a PDF of my web application using AlivePdf

1.1k views Asked by At

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?

1

There are 1 answers

0
James Ward On

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.