Actionscript 3 带有用户输入和计算字段的Actionscript 3.0表单使用AlivePDF将空保存为PDF

Actionscript 3 带有用户输入和计算字段的Actionscript 3.0表单使用AlivePDF将空保存为PDF,actionscript-3,pdf,flash-cs5,alivepdf,Actionscript 3,Pdf,Flash Cs5,Alivepdf,我在Flash Professional CS5.5中创建了一个表单,其中包含行、静态文本和文本字段,并使用Actionscript 3.0创建了接受用户输入的字段,然后计算这些用户输入并将其存储在用户无法编辑的字段中。我需要将填写的表格打印为PDF格式,并使用AlivePDF进行此操作。脚本创建PDF,但它是空的。如何将整个阶段捕获为PDF格式 这是.as文件中的代码 package { // Flash imports import flash.displa

我在Flash Professional CS5.5中创建了一个表单,其中包含行、静态文本和文本字段,并使用Actionscript 3.0创建了接受用户输入的字段,然后计算这些用户输入并将其存储在用户无法编辑的字段中。我需要将填写的表格打印为PDF格式,并使用AlivePDF进行此操作。脚本创建PDF,但它是空的。如何将整个阶段捕获为PDF格式

这是.as文件中的代码

package  {
        // Flash imports
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.display.SimpleButton;
        import flash.text.*;
        import fl.controls.CheckBox;
        import fl.accessibility.CheckBoxAccImpl; 
        import fl.controls.Button;
        import flash.filesystem.File;
        import flash.filesystem.FileStream;
        import flash.net.FileReference;
        import flash.net.FileReferenceList;
        //import flash.display.Sprite;
        import flash.media.CameraRoll;
        import flash.display.StageScaleMode;
        import flash.media.MediaPromise;
        import flash.events.MediaEvent;
        import flash.events.Event;

        //AlivePDF imports
        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;
        import org.alivepdf.images.ImageFormat;
        import org.alivepdf.saving.Download;
        import org.alivepdf.layout.Layout;

        public class mfDataCollection extends MovieClip {

            public function mfDataCollection() {
                init();
            }

            private function init():void {
                CheckBoxAccImpl.enableAccessibility();
                stage.focus = testDate;
                focusRect  = testDate;
                testDate.tabIndex = 1;  
                outsideTemp.tabIndex = 2; 
                buildingNumber.tabIndex = 3; 
                unitNumber.tabIndex = 4; 
                CAZ1AmbientCO.tabIndex = 5; 
                CAZ1Doors.tabIndex = 6; 
                CAZ1Fireplace.tabIndex = 7; 
                CAZ1CombustionAppliances.tabIndex = 8; 
                CAZ1Baseline.tabIndex = 9; 
                CAZ1Baseline.restrict = "-9-9";
                CAZ1Dryer.tabIndex = 10;
                CAZ1Dryer.restrict = "-9-9";
                CAZ1CheckUnderDoors.tabIndex = 11;
                CAZ1CheckUnderDoors.restrict = "-9-9";
                CAZ1AirHandler.tabIndex = 12;
                CAZ1AirHandler.restrict = "-9-9";
                CAZ1RecheckPressure.tabIndex = 13;
                CAZ1RecheckPressure.restrict = "-9-9";
                CAZ1SetToWC.tabIndex = 14;
                CAZ1WC.tabIndex = 15;
                CAZ1BaselineCopy.tabIndex = 15;
                CAZ1WCD.tabIndex = 16;
                CAZ1DepressurizationLimitsPassed.tabIndex = 17;
                CAZ1Monoxer.tabIndex = 18;
                CAZ1App1SmallestBTU.tabIndex = 19;
                CAZ1App1SpilliagePassed.tabIndex = 20;
                CAZ1App1AmbientCO2.tabIndex = 21;
                CAZ1App1AmbientCO2.restrict = "-9-9";
                CAZ1App1Draft.tabIndex = 22;
                CAZ1App1Draft.restrict = "-9-9";
                CAZ1App1DraftPassed.tabIndex = 23;
                CAZ1App1SpillageFailed.tabIndex = 24;
                CAZ1App1UndilutedCO.tabIndex = 25;
                CAZ1App1UndilutedCO.restrict = "-9-9";
                CAZ1App1ActionLevelsPassed.tabIndex = 26;
                CAZ1CompleteApp2.tabIndex = 27;
                CAZ1App2TestRequired.tabIndex = 28;
                ResetHousetoNormal.tabIndex = 29;
                OvenCO.tabIndex = 30;
                OvenCO.restrict = "0-9";
                LeftRearBurner.tabIndex = 31;
                LeftRearBurner.restrict = "0-9";
                LeftFrontBurner.tabIndex = 32;
                LeftFrontBurner.restrict = "0-9";
                RightFrontBurner.tabIndex = 33;
                RightFrontBurner.restrict = "0-9";
                RightRearBurner.tabIndex = 34;
                RightRearBurner.restrict = "0-9";
                RightFrontBurner.tabIndex = 35;
                CAZ1Dimensions.tabIndex = 36;
                CAZ2Dimensions.tabIndex = 37;
                GasLeakTestingPassed.tabIndex = 38;
                Notes.tabIndex = 39;
                IOUWorkOrder.tabIndex = 40;


                // Setup handlers for mouse clicks
                CAZ1Dryer.addEventListener(MouseEvent.CLICK, handleMouseClicks);
                CAZ1CheckUnderDoors.addEventListener(MouseEvent.CLICK, handleMouseClicks);
                CAZ1AirHandler.addEventListener(MouseEvent.CLICK, handleMouseClicks);
                CAZ1RecheckPressure.addEventListener(MouseEvent.CLICK, handleMouseClicks);
                CAZ1WC.addEventListener(MouseEvent.CLICK, handleMouseClicks);
                CAZ1BaselineCopy.addEventListener(MouseEvent.CLICK, handleMouseClicks);
                CAZ1WCD.addEventListener(MouseEvent.CLICK, handleMouseClicks);
            }

            private function handleMouseClicks(event:MouseEvent):void {

                var numCAZ1Baseline:Number = Number(CAZ1Baseline.text);
                var numCAZ1Dryer:Number = Number(CAZ1Dryer.text);
                var numCAZ1CheckUnderDoors:Number = Number(CAZ1CheckUnderDoors.text);
                var numCAZ1AirHandler:Number = Number(CAZ1AirHandler.text);
                var numCAZ1RecheckPressure:Number = Number(CAZ1RecheckPressure.text);
                var numCAZ1WC:Number = Number(CAZ1WC.text);
                var numCAZ1BaselineCopy:Number = numCAZ1Baseline;

                numCAZ1WC = Math.min(numCAZ1Dryer, numCAZ1CheckUnderDoors, numCAZ1AirHandler, numCAZ1RecheckPressure);
                CAZ1WC.text = String(numCAZ1WC);
                CAZ1BaselineCopy.text = String(numCAZ1BaselineCopy);
                var numCAZ1WCD:Number = Number(CAZ1WCD.text);
                numCAZ1WCD = numCAZ1WC - numCAZ1Baseline;
                CAZ1WCD.text = numCAZ1WCD.toFixed(1);
            }

            private function handleButtonClicks(event:MouseEvent):void {
                trace("You have clicked: " + event.currentTarget.name);
                var filename:String; // = "CAZ_Bldg-" + buildingNumber.text + "-" + unitNumber.text + ".pdf";
                var myPDF:PDF;
                switch (event.currentTarget.name) {
                    case "btnSaveAsFileButton":
                        exportPDF();
                        break;
                    default:
                        trace("You clicked something else");

                }
            }

            public function exportPDF() : void {
                var filename:String = "CAZ_Bldg-" + buildingNumber.text + "-" + unitNumber.text + ".pdf";
                trace("You are saving " + filename);
                var myPDF = new PDF(Orientation.PORTRAIT, Unit.INCHES, Size.A4);
                myPDF.setDisplayMode (Display.FULL_PAGE, Layout.SINGLE_PAGE);
                myPDF.addPage();
                var f:FileStream = new FileStream();
                        var file:File = File.userDirectory.resolvePath( filename );
                f.open( file, FileMode.WRITE);
                var bytes:ByteArray = myPDF.save(Method.LOCAL);
                f.writeBytes(bytes);
                f.close();
            }

        } // End of mfDataCollecion class

    } // End of package

我认为你实际上应该使用AlivePDF API(例如myPDF.addCell)重新创建你想要放在PDF文档中的内容……AlivePDF的全部目的是根据舞台上的内容创建PDF。还是我错过了什么?我在舞台上用Flash创建了这个表单。AlivePDF应该能够捕获舞台上的内容并将其保存为PDF。它另存为PDF,但为空白PDF。必须定义每一行、静态文本、文本字段、复选框或dropbox并不能让我的生活更轻松。这就像要求我从头开始写我自己的包。如何在不手动编写整个表单的情况下使用Flash stage完成我想做的事情?我认为您误解了AlivePDF使用Flash创建PDF而不是从SWF创建PDF:我认为您可以将stage打印为位图,然后将位图添加到PDF页面,但更好的选择是使用给定的APIUsing Flash How重新创建舞台布局确切地什么是AlivePDF实际保存的内容。我想也许我错过了什么。那么,你是说当我想保存文档时,我需要重新创建表单和数据输入字段、文本字段、下拉列表和复选框?在这个库上没有太多的帮助,而且那些帮助看起来已经过时了。我一整天都在试图简单地画一个矩形,然后在用AlivePDF创建的PDF文件中写入一些文本,但运气不好。任何帮助都将不胜感激,