<?xml version="1.0" encoding="utf-8"?>
<mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:mh="mh.components.*"
     viewSourceURL="srcview/index.html">

    <mx:Style source="styles/obsidian/obsidian.css" />
    <mx:Script>
        <![CDATA[
            import org.alivepdf.pdf.PDF;
            import org.alivepdf.layout.Orientation;
            import org.alivepdf.layout.Size;
            import org.alivepdf.layout.Unit;
            import org.alivepdf.display.Display;
            import org.alivepdf.saving.Method;
            import org.alivepdf.fonts.FontFamily;
            import org.alivepdf.fonts.Style;
            import org.alivepdf.colors.RGBColor;
            
            private var myPDF:PDF;

            function generatePDF ( e:MouseEvent )
            {
                // we create the PDF
                myPDF = new PDF(  Orientation.LANDSCAPE, Unit.MM, Size.LETTER );
                // we set the zoom to 100%
                myPDF.setDisplayMode ( Display.FULL_WIDTH ); 
                
        
                // we add a page
                myPDF.addPage();
                myPDF.addImage(dc_main);
                
                // to save the PDF your specificy the path to the create.php script
                // alivepdf takes care of the rest, if you are using AIR and want to save the PDF locally just use Method.LOCAL
                // and save the returned bytes on the disk through the FileStream class
                myPDF.save( Method.REMOTE, "http://alivepdf.bytearray.org/wp-content/demos/create.php", "drawing.pdf" );
                
            }
        ]]>
    </mx:Script>
        <mx:Button horizontalCenter="0" click="generatePDF(event)" label="Generate PDF" id="generate_btn" />
        
        <mx:Panel layout="absolute" title="Draw On Me" backgroundColor="#ffffff" borderThicknessBottom="10" left="20" right="20" top="20" bottom="20">
            <mx:Canvas x="0" y="0" width="100%" height="100%" backgroundColor="#ffffff">
                <mh:DrawableCanvas id="dc_main" backgroundColor="#ffff80" backgroundAlpha="0" width="100%" height="100%" y="0" x="0">
                </mh:DrawableCanvas>
            </mx:Canvas>
            
        </mx:Panel>

</mx:Application>