HTMLLoader打开pdf但不适合宽度

时间:2013-05-01 08:18:04

标签: html actionscript-3 flex

我有正确加载pdf文件的HTMLLoader,但我的问题是HTMLloader没有出现pdf的全宽(尽管我更改了HTMLLoader宽度,但pdf的Vscroll不会出现。)

private var pdf:HTMLLoader = new HTMLLoader();     
        private function init():void {
            if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK)  
            { 
                var request:URLRequest = new URLRequest("file:///D:/New%20folder/%D8%A7%D9%84%D9%83%D8%AA%D8%A7%D8%A8%20%D8%A7%D9%84%D8%AA%D9%81%D8%A7%D8%B9%D9%84%D9%8A/home.pdf");

                pdf.width = appCanvas.width-40; 
                pdf.height = appCanvas.height-60; 
                pdf.load(request);
                pdf.addEventListener(LocationChangeEvent.LOCATION_CHANGE, function(evt:LocationChangeEvent):void
                {
                    if(evt.location.toLocaleLowerCase().substring(evt.location.length-4) == "html" )
                    {
                        var str:String = escapeMultiByte(evt.location.slice(8));
                        str=unescape(evt.location);

                        var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

                        var mp:File = new File("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
                        nativeProcessStartupInfo.executable = mp;

                        var args:Vector.<String> = new Vector.<String>();
                        args.push(evt.location);

                        nativeProcessStartupInfo.arguments = args;
                        var process:NativeProcess = new NativeProcess();

                        process.start(nativeProcessStartupInfo);    

                        pdf.historyBack();
                    }
                });
                myWin.addChild(pdf); // Add the HTMLLoader to my HTML component
            } else { 
                Alert.show("PDF cannot be displayed. Error code:" + HTMLLoader.pdfCapability); 
            } 
        }

1 个答案:

答案 0 :(得分:1)

通过在加载HTMLLoader时重新更改appCanvas的宽度来解决它。 我在函数结束时添加了这段代码。

               setTimeout(function():void{
                appCanvas.width +=1;
                appCanvas.height +=1;
                appCanvas.width -=1;
                appCanvas.height -=1;
            },30);