PDF 在 Flex mx 中正确显示的问题:Windows/Reader X 中的 HTML 控件

发布于 2024-12-12 17:18:52 字数 1795 浏览 0 评论 0原文

我在 Flex 中的 mx:HTML 控件的可视区域之外显示 PDF 时遇到问题。当应用程序启动时 - mx:HTML 设置为一定大小,但如果应用程序最大化,则可以放大。复制它的条件如下:

  • 问题仅发生在 Windows 中(Windows 7,不在 Mac 上)
  • 问题仅发生在安装了 Reader X 的情况下(不适用于以前的版本)
  • 问题仅发生在运行构建的应用程序时,不会发生在调试/ FlashBuilder 的开发模式

下面是一些重现该问题的代码。组内的组看起来有点混乱,但我们的应用程序中还有其他内容,我已经删除了这些内容,只是为了有一个小型测试应用程序来重现该问题:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   width="1004" height="510" backgroundColor="#000000" >
<fx:Script>
    <![CDATA[
        import mx.events.FlexEvent;
        protected function press_clickHandler():void
        {
            htmlContent.location = "vt1_04_using_flash_builder.pdf";
        }
    ]]>
</fx:Script>
<fx:DesignLayer>
    <mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
        <mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
            <s:Button id="press" buttonMode="true" click="press_clickHandler()" 
                      right="84" top="8" label="Press"/>
        </mx:Panel>
        <s:Group id="groupCourseMain" height="100%" >
            <s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%">
                <mx:HTML id="htmlContent" top="0" bottom="0" width="100%" />     
            </s:Group>
        </s:Group>
    </mx:HDividedBox>
</fx:DesignLayer>
</s:WindowedApplication>

编辑:红色箭头显示阅读器中浮动灰色条的位置X 出现在可视区域之外:

在此处输入图像描述

I'm having an issue with the PDF displaying outside the viewable area of the mx:HTML control in Flex. When the application starts up - the mx:HTML is set to a certain size, but can be enlarged if the application is maximized. These are the following conditions to replicate it:

  • Issue only happens in Windows (Windows 7, not on Mac)
  • Issue only happens with Reader X installed (not with previous versions)
  • Issue only happens when running the built app, does not happen in debug / development mode from FlashBuilder

Here is some code to reproduce the issue. It looks a bit messy with the groups within groups, but there is other stuff in our application that I've stripped out just to have a small test app to reproduce the issue:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   width="1004" height="510" backgroundColor="#000000" >
<fx:Script>
    <![CDATA[
        import mx.events.FlexEvent;
        protected function press_clickHandler():void
        {
            htmlContent.location = "vt1_04_using_flash_builder.pdf";
        }
    ]]>
</fx:Script>
<fx:DesignLayer>
    <mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
        <mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
            <s:Button id="press" buttonMode="true" click="press_clickHandler()" 
                      right="84" top="8" label="Press"/>
        </mx:Panel>
        <s:Group id="groupCourseMain" height="100%" >
            <s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%">
                <mx:HTML id="htmlContent" top="0" bottom="0" width="100%" />     
            </s:Group>
        </s:Group>
    </mx:HDividedBox>
</fx:DesignLayer>
</s:WindowedApplication>

Edit: The red arrow shows where the floating grey bar in Reader X appears outside the viewable area:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雅心素梦 2024-12-19 17:18:52

这似乎是一个已知的bug,没有修复。

解决方法是在加载文档后以及每次调整其父组的大小时重新调整浏览器宽度的大小。诀窍是调整一个像素的大小以强制重绘。下面的代码似乎可以工作。这是我能做的最好的事情,也许还有更好的解决方案。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="1004" height="510" backgroundColor="#000000" >
   <fx:Script>
      <![CDATA[
         import mx.events.FlexEvent;
         import mx.events.ResizeEvent;
         protected function press_clickHandler():void
         {
            htmlContent.location = "test.pdf";
         }

         protected function htmlContent_completeHandler(event:Event):void
         {
            this.htmlContent.width = this.groupCourseHTML.width - 1;
         }

         protected function groupCourseHTML_resizeHandler(event:ResizeEvent):void
         {
            this.htmlContent.percentWidth = 100;
         }
      ]]>
   </fx:Script>
   <fx:DesignLayer>
      <mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
         <mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
            <s:Button id="press" buttonMode="true" click="press_clickHandler()" 
                      right="84" top="8" label="Press"/>
         </mx:Panel>
         <s:Group id="groupCourseMain" height="100%" >
            <s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%" resize="groupCourseHTML_resizeHandler(event)">
               <mx:HTML id="htmlContent" top="0" bottom="0" width="100%" complete="htmlContent_completeHandler(event)"/>     
            </s:Group>
         </s:Group>
      </mx:HDividedBox>
   </fx:DesignLayer>
</s:WindowedApplication>

This seems to be a known bug with no fix.

A workaround is to re-size the browser width after the document is loaded and every time its parent group is re-sized. The trick is to re-size one pixel off to force a redraw. The following code seems to work. That's the best I could do, there may be better solutions.

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="1004" height="510" backgroundColor="#000000" >
   <fx:Script>
      <![CDATA[
         import mx.events.FlexEvent;
         import mx.events.ResizeEvent;
         protected function press_clickHandler():void
         {
            htmlContent.location = "test.pdf";
         }

         protected function htmlContent_completeHandler(event:Event):void
         {
            this.htmlContent.width = this.groupCourseHTML.width - 1;
         }

         protected function groupCourseHTML_resizeHandler(event:ResizeEvent):void
         {
            this.htmlContent.percentWidth = 100;
         }
      ]]>
   </fx:Script>
   <fx:DesignLayer>
      <mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
         <mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
            <s:Button id="press" buttonMode="true" click="press_clickHandler()" 
                      right="84" top="8" label="Press"/>
         </mx:Panel>
         <s:Group id="groupCourseMain" height="100%" >
            <s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%" resize="groupCourseHTML_resizeHandler(event)">
               <mx:HTML id="htmlContent" top="0" bottom="0" width="100%" complete="htmlContent_completeHandler(event)"/>     
            </s:Group>
         </s:Group>
      </mx:HDividedBox>
   </fx:DesignLayer>
</s:WindowedApplication>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文