Issue with PDF displaying correctly in Flex mx:HTML control in Windows / Reader X

675 views Asked by At

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

1

There are 1 answers

0
Fernando Guayasamin On BEST ANSWER

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>