Need to print out a pdf file with button click

I am attempting to add a button to my application which will print out a .pdf file when clicked. The rest of the app is in AS3, so I guess this feature will need to be also.

I started out thinking I would need to print out a graphic which was created with AS3, but instead I will just be importing a .pdf into my library.

here is the code I have so far:


package {
    import flash.printing.PrintJob;
    import flash.printing.PrintJobOrientation;
    import flash.display.Stage;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    
       
    public class MessageWindow extends Sprite {
        private var sheet1:Sprite;
        
        //Change your constructor function so it looks like this:
public function MessageWindow() {
//Add an event listener for the button click
Printbtn.addEventListener(MouseEvent.CLICK,startPrint);
}

//Create a new function, so nothing happens right away:
private function startPrint(evt:MouseEvent):void
{
init();
printOnePerPage();
draw();
}
        private var printMessageWindow:MessageWindow;
           
        //public function PrintJobExample() {
            //init();
            //printOnePerPage();
//            printTwoPerPage();
//            printTopHalf();
            //draw();
      //  }
        
        private function init():void {
            sheet1 = new Sprite();
            MessageWindow(sheet1, "Certificate of Completion...", {x:10, y:50, width:80, height:130});

           
        }
        
        private function MessageWindow(sheet:Sprite, str:String, imgValue:Object):void {
            sheet.graphics.beginFill(0xEEEEEE);
            sheet.graphics.lineStyle(1, 0x000000);
            sheet.graphics.drawRect(0, 0, 100, 200);
            sheet.graphics.endFill();
            
            var txt:TextField = new TextField();
            txt.height = 200;
            txt.width = 100;
            txt.wordWrap = true;
            txt.text = str;
            
            if(imgValue != null) {
                var img:Sprite = new Sprite();
                img.graphics.beginFill(0xFFFFFF);
                img.graphics.drawRect(imgValue.x, imgValue.y, imgValue.width, imgValue.height);
                img.graphics.endFill();
                sheet.addChild(img);
            }
            sheet.addChild(txt);
        }
        
        private function printOnePerPage():void {
            var pj:PrintJob = new PrintJob();
            var pagesToPrint:uint = 0;
            if(pj.start()) {                
                if(pj.orientation == PrintJobOrientation.LANDSCAPE) {    
                    throw new Error("Without embedding fonts you must print one sheet per page with an orientation of portrait.");
                }
                
                sheet1.height = pj.pageHeight;
                sheet1.width = pj.pageWidth;
               

                try {
                    pj.addPage(sheet1);
                    pagesToPrint++;
                }
                catch(e:Error) {
                    // do nothing
                }

                
                catch(e:Error) {
                    // do nothing
                }

                if(pagesToPrint > 0) {
                    pj.send();
                }
            }
        }
        
        
        

        private function draw():void {
            var sheetWidth:Number = this.stage.stageWidth/2;
            var sheetHeight:Number = this.stage.stageHeight;
            
            addChild(sheet1);
            sheet1.width = sheetWidth;
            sheet1.height = sheetHeight;
            
            
        }        
    }
}